home *** CD-ROM | disk | FTP | other *** search
/ Hottest 6 / Hottest 6 (1996)(PDSoft)[!].iso / software / fredfish / 1076.lha / Programs / ZShell / ZShell.S < prev    next >
Text File  |  1995-04-07  |  224KB  |  11,256 lines

  1.  
  2. ****************************************************
  3. *********  ZSHELL (C) 1990,91 Paul Hayter  *********
  4. ********  updated to V2.5 by Martin Gierich ********
  5. ********    First major change: 08.06.93    ********
  6. *********    Last change: 07.04.95       *********
  7. ****************************************************
  8.  
  9. **ZShell V2.5.1, Changes since V2.4:
  10. *NEWCLI,RUN copies stacksize,appname,windowname
  11. *shift-in in PROMPT removed
  12. *DELETE DEVICE bug fixed
  13. *Crash in LIST with CTRL-C fixed
  14. *ASSIGN crash fixed
  15. *Partly localized using Fault()
  16. *AmigaGuide-viewer
  17. *removed C: as default path
  18. *correct inserting and restoring the cursorpos
  19. *EXECUTE executes scripts using AmigaDOS shell
  20. *ToolType: SCREEN=Depth/DisplayID/Overscan/Title
  21. *ToolType: DETACH
  22. *Filerequester CTRL-F
  23. *ToolType ICONIFY fixed
  24.  
  25. ;DEBUG    = 1
  26.  
  27. ***        TABSIZE = 8 Chars         ***
  28. ***     Local Labels named .A to .Z         ***
  29.  
  30. VERSION            equ    $1234
  31.  
  32. FLcheck        =0
  33. FLmatch        =1
  34. FLappicon    =2
  35. FLwild        =3
  36. FLerrors    =4
  37. FLdebug        =5
  38. FLcutline    =6
  39. FLall        =7
  40. FLhide        =8
  41. MaxFlags     =9
  42.  
  43. FIB            equ    260        ;FileInfoBlock
  44. ACCESS_READ        equ    -2
  45. ACCESS_WRITE        equ    -1
  46. MODE_READWRITE        equ    1004
  47. MODE_OLDFILE        equ    1005
  48. MODE_NEWFILE        equ    1006
  49.  
  50. SIGBREAKB_CTRL_C    equ    $C
  51. SIGBREAKB_CTRL_D    equ    $D
  52. SIGBREAKB_CTRL_E    equ    $E
  53. SIGBREAKB_CTRL_F    equ    $F
  54.  
  55. eb_CoolCapture    equ    46
  56. eb_ColdCapture    equ    42
  57. eb_WarmCapture    equ    50
  58. eb_KickMemPtr    equ    546
  59. eb_KickTagPtr    equ    550
  60. eb_KickCheckSum    equ    554
  61.     
  62. * FILE INFO BLOCK
  63. fib_DiskKey        equ  $0000
  64. fib_DirEntryType    equ  $0004
  65. fib_FileName        equ  $0008
  66. fib_Protection        equ  $0074
  67. fib_EntryType        equ  $0078
  68. fib_Size        equ  $007c
  69. fib_NumBlocks        equ  $0080
  70. fib_Date        equ  $0084
  71. fib_Comment        equ  $0090
  72. fib_Reserved        equ  $00e0
  73.  
  74. * INFO DATA STRUCTURE
  75. id_NumSoftErrors    equ    0
  76. id_UnitNumber        equ    4
  77. id_DiskState        equ    8
  78. id_NumBlocks        equ    12
  79. id_NumBlocksUsed    equ    16
  80. id_BytesPerBlock    equ    20
  81. id_DiskType        equ    24
  82. id_VolumeNode        equ    28
  83. id_InUse        equ    32
  84.  
  85. * TASK
  86. tc_State        equ    15
  87. tc_SigWait        equ    22
  88.  
  89. * PROCESS
  90.  
  91. pr_MsgPort        equ    92
  92. pr_SegList        equ    128
  93. pr_StackSize        equ    132
  94. pr_GlobVec        equ    136
  95. pr_TaskNum        equ    140
  96. pr_StackBase        equ    144
  97. pr_Result2        equ    148
  98. pr_CurrentDir        equ    152
  99. pr_CIS            equ    156
  100. pr_COS            equ    160
  101. pr_ConsoleTask        equ    164
  102. pr_FileSystemTask    equ    168
  103. pr_CLI            equ    172
  104. pr_ReturnAddr        equ    176
  105. pr_PktWait        equ    180
  106. pr_WindowPtr        equ    184
  107. pr_HomeDir        equ    188    KS2
  108. pr_Flags        equ    192
  109. pr_CES            equ    224
  110.  
  111. * COMMAND LINE INTERFACE
  112. cli_Result        equ    0
  113. cli_SetName        equ    4
  114. cli_CommandDir        equ    8
  115. cli_ReturnCode        equ    12
  116. cli_CommandName        equ    16
  117. cli_FailLevel        equ    20
  118. cli_Prompt        equ    24
  119. cli_StandardInput    equ    28
  120. cli_CurrentInput    equ    32
  121. cli_CommandFile        equ    36
  122. cli_Interactive        equ    40
  123. cli_Background        equ    44
  124. cli_CurrentOutput    equ    48
  125. cli_DefaultStack    equ    52
  126. cli_StandardOutput    equ    56
  127. cli_Module        equ    60
  128.  
  129. * FILE HANDLE
  130. fh_Link            equ    0
  131. fh_Port            equ    4
  132. fh_Type            equ    8
  133. fh_Buf            equ    12
  134. fh_Pos            equ    16
  135. fh_End            equ    20
  136.  
  137. * FILE LOCK
  138. fl_Link            equ    0
  139. fl_Key            equ    4
  140. fl_Access        equ    8
  141. fl_Task            equ    12
  142. fl_Volume        equ    16
  143.  
  144. * DATESTAMP
  145. ds_Days            equ    0
  146. ds_Minute        equ    4
  147. ds_Tick            equ    8
  148.  
  149. RETURN_OK        EQU  0
  150. RETURN_WARN        EQU  5
  151. RETURN_ERROR        EQU  10
  152. RETURN_BAD        EQU  15
  153. RETURN_FAIL        EQU  20
  154.  
  155. *Assign Stuff
  156. dl_Root        equ    34    APTR
  157. rn_Info        equ    24    BPTR
  158. rn_Flags    equ    52    LONG
  159. di_DevInfo    equ    4    BPTR
  160. di_NetHand    equ    16    BPTR
  161. dvi_Next    equ    0    BPTR
  162. dvi_Type    equ    4    LONG
  163. dvi_Task    equ    8    APTR
  164. dvi_Lock    equ    12    BPTR
  165. dvi_Handler    equ    16    (PathPtr)
  166. dvi_StackSize    equ    20
  167. dvi_LockList    equ    20
  168. dvi_Priority    equ    24
  169. dvi_Startup    equ    28
  170. dvi_SegList    equ    32
  171. dvi_GlobVec    equ    36
  172. dvi_Name    equ    40    BSTR
  173. dlt_device    equ    0    <-- contents of dvi_Type
  174. dlt_directory    equ    1
  175. dlt_volume    equ    2
  176. dlt_late    equ    3
  177. dlt_nonbind    equ    4
  178.  
  179. *Resident Stuff
  180. resi_link    equ    0    ;BPTR
  181. resi_usecount    equ    4    ;LONG
  182. resi_seglist    equ    8    ;BPTR
  183. resi_name    equ    12    ;BSTR
  184. resi_length    equ    4+4+4
  185.  
  186. *Icon Lib Stuff
  187. sm_Process    equ    $14
  188. sm_Segment    equ    $18
  189. sm_NumArgs    equ    $1c
  190. sm_ToolWindow    equ    $20
  191. sm_ArgList    equ    $24
  192. wa_Lock        equ    0
  193. wa_Name        equ    4
  194. do_Magic    equ    0    ;must be $e310
  195. do_Type        equ    $30
  196. do_ToolTypes    equ    $36
  197. do_ToolWindow    equ    $46
  198. do_StackSize    equ    $4a
  199.  
  200. *WAppMessage
  201. am_Type        equ    20
  202. am_NumArgs    equ    30
  203. am_ArgList    equ    34
  204.  
  205. * AVAIL STUFF
  206. MEMF_PUBLIC        equ 1
  207. MEMF_CHIP        equ 2
  208. MEMF_FAST        equ 4
  209. MEMF_CLEAR        equ $10000
  210. MEMF_LARGEST        equ $20000
  211.  
  212. * ACTIONS
  213. ACTION_SCREEN_MODE    EQU    994
  214. ACTION_INHIBIT        EQU    31
  215. ACTION_MORE_CACHE    EQU    18
  216. ACTION_RENAME_DISK    EQU    9
  217. ACTION_DIE        EQU    5
  218. ACTION_DISK_CHANGE    EQU    33
  219. ACTION_SET_DATE        EQU    34
  220. ACTION_DISK_INFO    EQU    25
  221. ACTION_WRITE_PROTECT    EQU    1023
  222. ACTION_FLUSH        EQU    27
  223. ACTION_READ        EQU    "R"
  224. ACTION_WRITE        EQU    "W"
  225.  
  226. dp_Link        EQU  $00   ;DosPacket Structure
  227. dp_Port        EQU  $04
  228. dp_Type        EQU  $08
  229. dp_Arg1        EQU  $14
  230. dp_SIZEOF    EQU  $30
  231.  
  232. sp_Msg        EQU  $00   ;StandardPacket Structure
  233. sp_Pkt        EQU  $14
  234. sp_SIZEOF    EQU  $44
  235.  
  236. LH_HEAD        equ    0
  237. LH_TAIL        equ    4
  238. LH_TAILPRED    equ    8
  239. LH_TYPE        equ    12
  240. LH_PAD        equ    13
  241. LH_SIZE        equ    14
  242.  
  243. LN_SUCC        equ    0
  244. LN_PRED        equ    4
  245. LN_TYPE        equ    8
  246. LN_PRI        equ    9
  247. LN_NAME        equ    10
  248. LN_SIZE        equ    14
  249.  
  250. NT_MSGPORT    EQU  4
  251.  
  252. MP_FLAGS    EQU  $0E   ;Message Port Structure
  253. MP_SIGBIT    EQU  $0F   ;Signal bit number
  254. MP_SIGTASK    EQU  $10   ;Task to be signalled
  255. MP_MSGLIST    EQU  $14   ;Message linked list
  256. MP_SIZE        EQU  $22
  257.  
  258. mn_ReplyPort    equ    14
  259. mn_Length    equ    18
  260. mn_Size        equ    20
  261.  
  262. PA_SIGNAL    EQU  0       ;PutAction messages
  263.  
  264.     
  265. * LIBRARY CALLS
  266. * EXEC
  267. _LVOOpenLibrary        equ    -552
  268. _LVOOldOpenLibrary    equ    -408
  269. _LVOCloseLibrary    equ    -414
  270. _LVOSetFunction        equ    -420
  271. _LVOAllocMem        equ    -198
  272. _LVOFreeMem        equ    -210
  273. _LVORawDoFmt        equ    -522
  274. _LVORawMayGetChar    equ    -510
  275. _LVOFindTask        equ    -294
  276. _LVOSetTaskPri        equ    -300
  277. _LVOAddTask        equ    -282
  278. _LVORemTask        equ    -288
  279. _LVOForbid        equ    -132
  280. _LVOPermit        equ    -138
  281. _LVOAvailMem        equ    -216
  282. _LVOAddPort        equ    -354
  283. _LVORemPort        equ    -360
  284. _LVOFindPort        equ    -390
  285. _LVOPutMsg        equ    -366
  286. _LVOGetMsg        equ    -372
  287. _LVOReplyMsg        equ    -378
  288. _LVOWaitPort        equ    -384
  289. _LVOWait        equ    -318
  290. _LVOSignal        equ    -324
  291. _LVOSetSignal        equ    -306
  292. _LVOAllocSignal        equ    -330
  293. _LVOFreeSignal        equ    -336
  294. _LVOOpenDev        equ    -444
  295. _LVOCloseDev        equ    -450
  296. _LVODoIO        equ    -456
  297. _LVOCreateMsgPort    equ    -666    KS 2.0+
  298. _LVODeleteMsgPort    equ    -672
  299.  
  300. * DOS
  301. _LVOSetProtection    equ    -186
  302. _LVOExecute        equ    -222
  303. _LVOOutput        equ    -60
  304. _LVOWrite        equ    -48
  305. _LVOLock        equ    -84
  306. _LVOUnLock        equ    -90
  307. _LVODupLock        equ    -96
  308. _LVOExamine        equ    -102
  309. _LVOExNext        equ    -108
  310. _LVOOpen        equ    -30
  311. _LVOClose        equ    -36
  312. _LVORead        equ    -42
  313. _LVOInput        equ    -54
  314. _LVODeleteFile        equ    -72
  315. _LVORename        equ    -78
  316. _LVOCreateDir        equ    -120
  317. _LVOCurrentDir        equ    -126
  318. _LVOIoErr        equ    -132
  319. _LVOParentDir        equ    -210
  320. _LVOLoadSeg        equ    -150
  321. _LVOUnLoadSeg        equ    -156
  322. _LVOCreateProc        equ    -138
  323. _LVOInfo        equ    -114
  324. _LVODateStamp        equ    -192
  325. _LVOSeek        equ    -66
  326. _LVODeviceProc        equ    -174
  327. _LVODelay        equ    -198
  328. _LVOSetComment        equ    -180
  329. _LVOIsInteractive    equ    -216
  330. _LVOReadLink        equ    -438    KS 2.0+
  331. _LVOMakeLink        equ    -444
  332. _LVOFault        equ    -468
  333. _LVOPrintFault        equ    -474
  334. _LVOAssignLock        equ    -612
  335. _LVOAssignLate        equ    -618
  336. _LVOAssignPath        equ    -624
  337. _LVOAssignAdd        equ    -630
  338. _LVORemAssignList    equ    -636
  339. _LVOFormat        equ    -714
  340. _LVOAddBuffers        equ    -732
  341. _LVOFilePart        equ    -870
  342. _LVOPathPart        equ    -876
  343. _LVOInhibit        equ    -726
  344. _LVOParsePatternNC    equ    -966
  345. _LVOMatchPatternNC    equ    -972
  346. _LVONameFromLock    equ    -402
  347.  
  348. *Intuition
  349. _LVOPrintIText        equ    -216
  350. _LVODisplayAlert    equ    -90
  351. _LVODisplayBeep        equ    -96
  352. _LVOLockIBase        equ    -414
  353. _LVOUnlockIBase        equ    -420
  354. _LVORefreshWindowFrame    equ    -456
  355. _LVOSizeWindow        equ    -288
  356. _LVOMoveWindow        equ    -168
  357. _LVOActivateWindow    equ    -450
  358. _LVORemakeDisplay    equ    -384
  359. _LVOMakeScreen        equ    -378
  360. _LVORethinkDisplay    equ    -390
  361. _LVOCloseScreen        equ    -66
  362. _LVOOpenScreenTagList    equ    -612    KS2.0+
  363. _LVOPubScreenStatus    equ    -552
  364.  
  365. *Icon
  366. _LVOGetDiskObject    equ    -78
  367. _LVOGetDefDiskObject    equ    -120
  368. _LVOPutDiskObject    equ    -84
  369. _LVOFreeDiskObject    equ    -90
  370. _LVOFindToolType    equ    -96
  371. _LVOMatchToolValue    equ    -102
  372.  
  373. *Workbench
  374. _LVOAddAppIconA        equ    -60    KS2.0+
  375. _LVOAddAppWindowA    equ    -48
  376. _LVORemoveAppIcon    equ    -66
  377. _LVORemoveAppWindow    equ    -54
  378. _LVOWBInfo        equ    -90
  379.  
  380. *Asl
  381. _LVOAllocFileRequest    equ    -30
  382. _LVOFreeFileRequest    equ    -36
  383. _LVORequestFile        equ    -42
  384.  
  385. *XPKMaster
  386. _LVOXpkExamine        equ    -36
  387. _LVOXpkUnpack        equ    -48
  388.  
  389. *AmigaGuide
  390. _LVOOpenAmigaGuideA    equ    -54
  391. _LVOCloseAmigaGuide    equ    -66
  392.  
  393.  
  394. rf_File        = 4
  395. rf_Dir        = 8
  396.  
  397. XPK_InName    = $80005851    filename
  398. XPK_OutName    = $80005860    filename
  399. XPK_GetError    = $80005875    buffer
  400. XPK_TaskPri    = $8000587f    ubyte
  401.  
  402.         RSRESET
  403. ;NewAmigaGuide-structure
  404. nag_Lock    RS.L    1
  405. nag_Name    RS.L    1
  406. nag_Screen    RS.L    1
  407. nag_PubScreen    RS.L    1
  408. nag_HostPort    RS.L    1
  409. nag_ClientPort    RS.L    1
  410. nag_BaseName    RS.L    1
  411. nag_Flags    RS.L    1
  412. nag_Context    RS.L    1
  413. nag_Node    RS.L    1
  414. nag_Line    RS.L    1
  415. nag_Extens    RS.L    1
  416. nag_Client    RS.L    1
  417. NewAmigaGuide_SIZEOF    RS.W    0
  418.  
  419. * DOS LIBRARY
  420. dl_A2            equ    42
  421.  
  422. *SYSTEM0 stuff!!!!!!!!!!
  423. REG_SysBase    equr a6
  424.  
  425. callsys    macro
  426.     jsr _LVO\1(REG_SysBase)
  427.     endm
  428.  
  429. * parameter offsets & stack
  430. ;SAVED_REGS    reg    a2-a6/d2-d3
  431. DELTA        equ    7*4
  432. ARG_NAME    equ    4+DELTA
  433. ARG_SEGLIST    equ    8+DELTA
  434. ARG_ARGS    equ    12+DELTA
  435.  
  436. * additional return codes
  437. NO_CLI        equ    -1
  438. NO_MEM        equ    -2
  439.  
  440. * local constants
  441. MAXBSTR        equ    255
  442. LF        equ    10
  443.  
  444. * register usage
  445. REG_Result    equr    d3
  446. REG_Process    equr    a2      ;may not be A4, see below!
  447. REG_CLI        equr    a3
  448. REG_CIS        equr    a4      ;may not be A3, see below!
  449. REG_PrevStack    equr    a1    ;V2.0 changed from a5 to a1
  450.  
  451. * local stack frame
  452. * STRUCTURE      StackFrame,0
  453.         RSRESET
  454. sf_CommandName    RS.B    MAXBSTR+1        ;BSTR, length byte!
  455. sf_CommandArgs    RS.B    MAXBSTR+1        ;not a BSTR, LF-terminated!
  456. sf_PrevStack        RS.L    1
  457. sf_SaveReturnAddr    RS.L    1
  458. sf_SaveModule        RS.L    1
  459. sf_SaveCommandName    RS.L    1
  460. sf_StackBase    RS.L    1
  461. sf_StackSize    RS.L    1
  462. sf_PushSize    RS.L    1
  463. sf_Process    RS.L    1
  464. sf_CLI        RS.L    1
  465. sf_CIS        RS.L    1
  466. sf_SCB_Buf    RS.L    1
  467. sf_SCB_Pos    RS.L    1
  468. sf_SCB_End    RS.L    1
  469. sf_Membase    RS.L    1
  470. sf_SIZEOF    RS.W    0
  471.  
  472. *Constants (only LONGS!)
  473. SHELLINE_SIZE    equ    256    V1.30
  474. CLIBUF_SIZE    equ    256
  475. NEWPRINTSIZE    equ    200
  476. HISTORY_SIZE    equ    1024    MUST BE POWER OF 2
  477.  
  478. * THE GENERAL MEMORY BLOCK (LONGS!)
  479.         RSRESET
  480. blockbase    RS.B    260    the fib or info goes here
  481. sp_node        RS.B    14    DOSpacket
  482. sp_reply    RS.L    1
  483. sp_length    RS.W    1
  484. sp_link        RS.L    1
  485. sp_port        RS.L    1
  486. packettype    RS.L    1
  487. sp_res1        RS.L    1
  488. sp_res2        RS.L    1
  489. myArg1        RS.L    1
  490. myArg2        RS.L    1
  491. myArg3        RS.L    1
  492. myArg4        RS.L    1
  493. myArg5        RS.L    1
  494. myArg6        RS.L    1
  495. myArg7        RS.L    1
  496. packettask    RS.L    1
  497. devproc        RS.L    1    endofpacket
  498. unusedlock    RS.L    1
  499. last_failcode    RS.L    1
  500. outhandle    RS.L    1
  501. inhandle    RS.L    1
  502. unusedin    RS.B    40
  503. unusedout    RS.B    40
  504. stdout        RS.L    1
  505. stdin        RS.L    1
  506. EntryA0        RS.L    1
  507. better_Seglist    RS.L    1
  508. parm1        RS.L    1    addr of each parameter within shelline
  509. parm2        RS.L    1
  510. parm3        RS.L    1
  511. parm4        RS.L    1
  512. parm5        RS.L    1
  513. parm6        RS.L    1
  514. parm7        RS.L    1
  515. parm8        RS.L    1
  516. parm9        RS.L    1
  517. parm10        RS.B    4*16    16 extra parms
  518. endofparms    RS.L    1    for NULL end
  519.  
  520. shelline    RS.B    SHELLINE_SIZE
  521. endofshelline
  522. CLIbuf        RS.B    CLIBUF_SIZE
  523. NewPrintBuffer    RS.B    NEWPRINTSIZE
  524. errorstack    RS.L    1
  525. topstack    RS.L    1
  526. stacksize    RS.L    1
  527. temp1        RS.L    1
  528. temp2        RS.L    1
  529. temp3        RS.L    1
  530. temp4        RS.L    1
  531. tempbuf        RS.B    2*SHELLINE_SIZE    double shellinesizebuffer
  532. temp2buf    RS.B    80    80 char temp buffer
  533. dosbase        RS.L    1
  534. intuibase    RS.L    1
  535. Result2        RS.L    1
  536. kickver        RS.W    1
  537. old_prompt    RS.L    1
  538. old_setname    RS.L    1
  539. old_homedir    RS.L    1
  540. Unused        RS.W    1
  541. CLIptr        RS.L    1
  542. Flags        RS.L    1
  543. prompt_cr    RS.L    1
  544. ConsoleSwitch    RS.L    1
  545. count_line    RS.L    1
  546. ignoreit    RS.B    60    for filenamecompletition
  547. OldCTask    RS.L    1
  548. OldCIS        RS.L    1
  549. OldCOS        RS.L    1
  550. bordersize    RS.L    1
  551. scsize        RS.L    1
  552. scaddr        RS.L    1
  553. scptr        RS.L    1
  554. scflag        RS.B    1
  555. openwin_flag    RS.B    1
  556. noresi_flag    RS.B    1
  557. noreview_flag    RS.B    1
  558. ReviewMem    RS.L    1
  559. ReviewPtr    RS.L    1
  560. ReviewSize    RS.L    1
  561. gather_ptr    RS.L    1
  562. tempbytes    RS.W    1
  563. gather        RS.B    80    for CSI string and error-string
  564. unused_area    RS.B    170
  565. now        RS.L    1
  566. nost        RS.L    1
  567. then        RS.L    1
  568. past        RS.B    HISTORY_SIZE    history buffer=1024 bytes
  569. thistask    RS.L    1
  570. un_area        RS.B    46
  571. first_set_defn    RS.L    1
  572. MPipePtr    RS.L    1
  573. app_name    RS.L    1
  574. wbbase        RS.L    1
  575. losecdir    RS.L    1    unused
  576. temp5        RS.L    1
  577. temp6        RS.L    1
  578. temp7        RS.L    1
  579. appwinport    RS.L    1
  580. appwindow    RS.L    1
  581. pubscreen    RS.L    1
  582. pubname        RS.L    1
  583. windowptr    RS.L    1
  584. unused_str    RS.B    8    UNUSED !
  585. windowname    RS.L    1
  586. mem_addr    RS.L    1
  587. wild_flag    RS.B    1
  588. unused_flag    RS.B    1
  589. wild_string    RS.B    80    allow 80 chars for wildcard
  590. date_mark    RS.L    3    3 lwords
  591. mem_mark    RS.L    3    3 lwords chip/fast/total
  592. CD_string    RS.B    80    Allow 80 bytes.
  593. prompt_string    RS.B    80    Allow 80 bytes.
  594. prompt_args    RS.B    40    Allow 40 bytes
  595. line_count    RS.W    1
  596. mult_comm_flag    RS.W    1    
  597. next_comm_ptr    RS.L    1
  598. break_flag    RS.B    1
  599. unused_level    RS.B    3
  600. cd_block    RS.L    1
  601. cd_volnode    RS.L    1
  602. recurs_flag    RS.W    1
  603. indent_count    RS.W    1
  604. resi_flag    RS.B    1
  605. forcediskflag    RS.B    1
  606. CLIflag        RS.B    1
  607. WBflag        RS.B    1
  608. oldwindowptr    RS.L    1
  609. wb_msg        RS.L    1
  610. iconbase    RS.L    1
  611. diskobj        RS.L    1
  612. filesys_old    RS.L    1
  613. cdir_old    RS.L    1
  614. cdback        RS.L    1
  615. ctrl_codes    RS.B    16    Keyboard-CTRL-Codes
  616. if_flag        RS.B    1
  617. if_condition    RS.B    1
  618. goto_flag    RS.B    1
  619. memclk_flag    RS.B    1
  620. dest_label    RS.B    60
  621. unused_me    RS.L    1
  622. mem_offset_addr    RS.L    1
  623. io_Message    RS.B    20    io-request (timer)
  624. io_Device    RS.L    1
  625. io_Unit        RS.L    1
  626. io_Command    RS.W    1
  627. io_Flags    RS.B    1
  628. io_Error    RS.B    1
  629. tv_secs        RS.L    1
  630. tv_micro    RS.L    1
  631. io_pad        RS.L    2    ;don't remove
  632. sizeofblk    RS.W    0
  633.  
  634.  
  635.  
  636. ********************************************
  637.  
  638. ;    SECTION    MYSHELL,CODE
  639.     
  640. ;Try to open dos then do the shell
  641. start    moveq    #-1,d7
  642.     move.l    a0,a3
  643.     move.l    4.w,a6
  644.     move.l    #sizeofblk,d0
  645.     move.l    #1+1<<16,d1        "memf_public" & clear it
  646.     jsr    _LVOAllocMem(a6)    alloc general mem block
  647.     tst.l    d0
  648.     beq    blkfail
  649.     move.l    d0,a5            A5=MEMBASE
  650.     move.l    sp,topstack(a5)
  651.     move.l    a3,EntryA0(a5)
  652.     move.w    20(a6),kickver(a5)        Kickstart-Version
  653.     lea    intuiname(pc),a1
  654.     jsr    _LVOOldOpenLibrary(a6)
  655.     tst.l    d0
  656.     beq    intfail
  657.     move.l    d0,intuibase(a5)
  658.     lea    dosname(pc),a1
  659.     jsr    _LVOOldOpenLibrary(a6)
  660.     tst.l    d0
  661.     beq    dosfail
  662.     move.l    d0,dosbase(a5)
  663.     clr.w    CLIflag(a5)        delete CLI&WBflag
  664.     sub.l    a1,a1
  665.     jsr    _LVOFindTask(a6)
  666.     move.l    d0,thistask(a5)        save this task address
  667.     move.l    d0,a2
  668.     move.l    pr_CLI(a2),d0
  669.     bne.s    .A
  670.     subq.w    #1,CLIflag(a5)        WB-Start
  671.     lea    pr_MsgPort(a2),a0
  672.     IFND    DEBUG
  673.     jsr    _LVOWaitPort(a6)
  674.     ENDC
  675.     lea    pr_MsgPort(a2),a0
  676.     jsr    _LVOGetMsg(a6)
  677.     move.l    d0,wb_msg(a5)
  678.     beq.s    .C
  679.     move.l    d0,a0
  680.     clr.l    sm_Segment(a0)        Clear Seg-Descriptor
  681. .C    move.l    pr_StackSize(a2),stacksize(a5)
  682.     move.l    pr_SegList(a2),d0
  683.     beq.s    .B
  684.     lsl.l    #2,d0
  685.     move.l    d0,a0
  686.     clr.l    12(a0)            Clear SegPointer
  687.     bra.s    .B
  688. .A    lsl.l    #2,d0            CLI-Start
  689.     move.l    d0,a2
  690.     move.l    cli_DefaultStack(a2),d0
  691.     lsl.l    #2,d0
  692.     move.l    d0,stacksize(a5)    save stacksize
  693.     clr.l    cli_Module(a2)        do not free seglist
  694.     cmp.b    #"r",1(a3)
  695.     bne.s    .B
  696.     addq.b    #1,noresi_flag(a5)
  697. .B    move.l    dosbase(a5),a6        A6=DOSBASE
  698.     tst.b    noresi_flag(a5)
  699.     bne.s    doIT
  700.     lea    ZShellName(pc),a4
  701.     bsr    search_res2
  702.     lea    start-4(pc),a1
  703.     tst.l    d0
  704.     IFD    DEBUG
  705.     bra.s    doIT
  706.     ENDC
  707.     beq.s    cresi
  708.     lsl.l    #2,d0
  709.     move.l    d0,a2
  710.     nop
  711.     nop
  712. VCheck    cmp.w    #VERSION,VCheck-start+6(a2)
  713.     bne    normex
  714.     addq.l    #1,resi_usecount(a0)
  715.     cmp.l    a1,a2
  716.     beq.s    doIT        running as resident
  717.     jmp    JumpIn-start+4(a2) Jump to JumpIn, but in the resident Code
  718.     nop
  719. JumpIn    move.l    a1,d1    here it arrives
  720.     lsr.l    #2,d1
  721.     jsr    _LVOUnLoadSeg(a6)    free old mem
  722.     bra.s    doIT
  723. cresi    move.l    a1,d3
  724.     lsr.l    #2,d3
  725.     bsr    create_resi    make zshell resident
  726.     bne    crfail
  727.     addq.l    #1,resi_usecount(a2)
  728. doIT    bsr    shell            ***    DO IT    ***
  729.     bsr    deallocate_sets
  730.     bsr    reviewend
  731.     bsr    KillAppWin
  732.     bsr    RemoveCLI
  733.     lea    start-4(pc),a0
  734.     move.l    a0,d6
  735.     lsr.l    #2,d6
  736.     tst.b    noresi_flag(a5)
  737.     bne.s    normex
  738.     lea    ZShellName(pc),a4
  739.     bsr    search_res2
  740.     tst.l    d0
  741.     beq.s    crfail
  742.     subq.l    #1,resi_usecount(a0)
  743.     tst.l    d7
  744.     bne.s    crfail
  745.     moveq    #1,d1
  746.     cmp.l    resi_usecount(a0),d1
  747.     bne.s    crfail
  748.     move.l    d0,d6    kill the ZShell-Resident
  749.     move.l    a0,a2
  750.     move.l    d2,a0
  751.     move.l    resi_link(a2),resi_link(a0)
  752.     clr.l    resi_link(a2)
  753.     move.l    a2,d1
  754.     lsr.l    #2,d1
  755.     jsr    _LVOUnLoadSeg(a6)
  756. normex    bsr    giveman        free manualmem
  757.     move.l    thistask(a5),a0
  758.     tst.b    CLIflag(a5)    How to UnLoad the Segment
  759.     beq.s    .A
  760.     move.l    pr_SegList(a0),d0
  761.     beq.s    .B
  762.     lsl.l    #2,d0
  763.     move.l    d0,a0
  764.     move.l    d6,12(a0)    Store Segment in SegPointer (WB/RUN)
  765. .B    move.l    wb_msg(a5),d0
  766.     beq.s    crfail
  767.     move.l    d0,a0
  768.     move.l    d6,sm_Segment(a0)    and in Seg-Descriptor    (WB)
  769.     bra.s    crfail
  770. .A    move.l    pr_CLI(a0),a0
  771.     add.l    a0,a0
  772.     add.l    a0,a0
  773.     move.l    d6,cli_Module(a0)    Store Segment in Module    (CLI)
  774. crfail    move.l    dosbase(a5),a1
  775.     move.l    4.w,a6
  776.     jsr    _LVOCloseLibrary(a6)
  777. dosfail    move.l    intuibase(a5),a1
  778.     jsr    _LVOCloseLibrary(a6)
  779. intfail    move.l    wb_msg(a5),d2
  780.     move.l    a5,a1
  781.     move.l    #sizeofblk,d0
  782.     jsr    _LVOFreeMem(a6)
  783.     tst.l    d2
  784.     beq.s    .A
  785.     jsr    _LVOForbid(a6)    (what for ?)
  786.     move.l    d2,a1        WB-Message
  787.     jmp    _LVOReplyMsg(a6)    never returns !
  788. .A    moveq    #0,d0
  789.     rts
  790. blkfail    moveq    #RETURN_ERROR,d0
  791.     rts
  792.  
  793. initialise_default
  794.     move.l    CLIptr(a5),a0
  795.     moveq    #16,d0
  796.     move.l    d0,cli_FailLevel(a0)
  797.     move.b    #LF,past(a5)
  798.     lea    prompt_args_tx(pc),a0    init prompt
  799.     lea    prompt_args(a5),a1
  800. .C    move.b    (a0)+,(a1)+
  801.     bne.s    .C
  802.     moveq    #ctrl_inite-ctrl_init-1,d0
  803.     lea    ctrl_init(pc),a0
  804.     lea    ctrl_codes(a5),a1
  805. .B    move.b    (a0)+,(a1)+        init ctrl-codes
  806.     dbra    d0,.B
  807.     rts
  808.  
  809. InitAppWin
  810.     tst.l    ConsoleSwitch(a5)    test noraw-mode
  811.     beq.s    .A
  812.     move.l    4.w,a6
  813.     jsr    _LVOCreateMsgPort(a6)    get msg-port
  814.     move.l    d0,appwinport(a5)
  815.     beq.s    .A
  816.     move.l    d0,a2
  817.     move.l    dosbase(a5),a6
  818.     bsr    GetWindowPtr        get ptr to window
  819.     move.l    d0,d2
  820.     beq.s    .A
  821.     bsr    OpenWBLib
  822.     beq    .A
  823.     moveq    #0,d0
  824.     moveq    #0,d1
  825.     move.l    d2,a0
  826.     sub.l    a1,a1
  827.     exg.l    a1,a2
  828.     jsr    _LVOAddAppWindowA(a6)    make appwin
  829.     move.l    d0,appwindow(a5)
  830. .A    move.l    dosbase(a5),a6
  831.     rts
  832.  
  833. GetWindowPtr    ;pointer to Console-Window to a0 (0 for fail)
  834.     move.l    thistask(a5),a0
  835.     move.l    pr_ConsoleTask(a0),packettask(a5)
  836.     bsr    GetDiskInfo
  837.     moveq    #0,d0
  838.     tst.l    sp_res1(a5)
  839.     beq.s    .A
  840.     move.l    id_VolumeNode(a5),d0    it is in here !
  841. .A    rts
  842.  
  843. KillAppWin
  844.     move.l    appwindow(a5),d2
  845.     beq.s    .B
  846.     bsr    OpenWBLib
  847.     move.l    d2,a0
  848.     jsr    _LVORemoveAppWindow(a6)
  849. .B    move.l    appwinport(a5),d0
  850.     beq.s    .A
  851.     move.l    d0,a0
  852.     move.l    4.w,a6
  853.     jsr    _LVODeleteMsgPort(a6)
  854. .A    move.l    dosbase(a5),a6
  855.     rts
  856.  
  857. * PRINT DECIMAL print D0 as decimal
  858. print10    movem.l    d0/a0-a1,-(sp)
  859.     move.l    d0,-(sp)
  860.     move.l    sp,a1
  861.     lea    format(pc),a0
  862.     bsr    new_print
  863.     addq.l    #4,sp
  864.     movem.l    (sp)+,d0/a0-a1
  865.     rts
  866.  
  867. * PRINT HEXADECIMAL address in D0
  868. printADR movem.l    d0/a0-a1,-(sp)
  869.     move.l    d0,-(sp)
  870.     move.l    sp,a1
  871.     lea    formatADR(pc),a0
  872.     bsr    new_print
  873.     addq.l    #4,sp
  874.     movem.l    (sp)+,d0/a0-a1
  875.     rts
  876.  
  877. *PRINT STRING at a1    ;saves some of the important low registers
  878. pr_space lea    space(pc),a1
  879.     bra.s    pr_string
  880. pr_tab    lea tab(pc),a1
  881.     bra.s pr_string
  882. pr_prompt lea prompt_string(a5),a1
  883.     bra.s pr_string    
  884. pr_lf    lea lf(pc),a1
  885. pr_string movem.l    d0-d3/a0-a3,-(sp)    print String in a1
  886.     move.l    a1,d2
  887.     moveq    #-1,d3
  888. .A    addq.l    #1,d3
  889.     tst.b    (a1)+
  890.     bne.s    .A
  891.     move.l    outhandle(a5),d1
  892.     beq.s    .B
  893.     jsr    _LVOWrite(a6)
  894. .B    movem.l    (sp)+,d0-d3/a0-a3
  895.     rts
  896.  
  897. *CHECK WHETHER A SCRIPT NAME WAS TYPED ON ENTRY TO ZSHELL
  898. execscr    move.l    EntryA0(a5),d0
  899.     move.l    d0,parm1(a5)
  900.     beq.s    .C
  901.     move.l    d0,a0
  902.     tst.b    (a0)
  903.     bne    xz2    ;NB this is OK, xz2 will pop the return addr 
  904.             ;and jump to chorus
  905.     rts
  906. .C    moveq    #-1,d1        handle DEFAULT SCRIPT FILE s:zstart
  907.     bsr    changeWindowPtr    disable volume requesters
  908.     lea    defscript(pc),a2
  909.     move.l    a2,d1
  910.     moveq    #ACCESS_READ,d2
  911.     jsr    _LVOLock(a6)
  912.     moveq    #0,d1
  913.     bsr    changeWindowPtr
  914.     move.l    d0,d1    test lock
  915.     beq.s    .B
  916.     jsr    _LVOUnLock(a6)
  917.     move.l    a2,a0
  918.     bra    xz2
  919. .B    rts
  920.  
  921. CheckForbid
  922.     move.l    4.w,a0        Check for not closed
  923.     moveq    #-1,d0
  924.     cmp.b    294(a0),d0    Disables or
  925.     bne.s    .A
  926.     cmp.b    295(a0),d0    Forbids
  927.     beq.s    .B
  928. .A    move.b    d0,294(a0)    and avoids crashes !
  929.     move.b    d0,295(a0)
  930.     lea    Forbidtx(pc),a1
  931.     bsr    pr_stringlf
  932. .B    rts
  933.  
  934. *********************************
  935. *    MAIN BIT        *
  936. *********************************
  937. shell    move.l    sp,errorstack(a5)
  938.     lea    appicontx(pc),a0
  939.     move.l    a0,app_name(a5)
  940.     move.l    #%111010010,Flags(a5)
  941.     bsr    CreateCLI
  942.     bne    cloga            exit on error
  943.     move.l    thistask(a5),a3
  944.     move.l    pr_CLI(a3),a2
  945.     add.l    a2,a2
  946.     add.l    a2,a2
  947.     move.l    a2,CLIptr(a5)
  948.     move.l    cli_Prompt(a2),old_prompt(a5)
  949.     lea    prompt_args(a5),a0
  950.     move.l    a0,d0
  951.     lsr.l    #2,d0
  952.     move.l    d0,cli_Prompt(a2)
  953.     move.l    cli_SetName(a2),old_setname(a5)
  954.     lea    CD_string(a5),a0
  955.     move.l    a0,d0
  956.     lsr.l    #2,d0
  957.     move.l    d0,cli_SetName(a2)
  958.     cmp.w    #36,kickver(a5)
  959.     blo.s    .C
  960.     move.l    pr_HomeDir(a3),old_homedir(a5)
  961.     clr.l    pr_HomeDir(a3)
  962.     move.l    dl_Root(a6),a0
  963.     bset    #24,rn_Flags(a0)    set wildstar flag
  964.     bsr    InitAppWin
  965. .C    jsr    _LVOOutput(a6)    SAVE THE CONSOLE HANDLERS
  966.     move.l    d0,outhandle(a5)
  967.     move.l    d0,stdout(a5)
  968.     jsr    _LVOInput(a6)
  969.     move.l    d0,inhandle(a5)
  970.     move.l    d0,stdin(a5)
  971.     move.l    pr_CurrentDir(a3),d1
  972.     jsr    _LVODupLock(a6)
  973.     move.l    d0,cdback(a5)
  974.     bsr    GetWindowPtr
  975.     beq.s    .A
  976.     move.l    d0,windowptr(a5)
  977.     move.l    d0,pr_WindowPtr(a3)
  978. .A    cmp.b    #1,WBflag(a5)
  979.     beq.s    notini        run/newcli
  980.     bsr    initialise_default
  981. notini    tst.b    CLIflag(a5)
  982.     beq.s    .A
  983.     moveq    #-127,d0
  984.     subq.l    #2,d0
  985.     bsr    GetMessage    Welcome-Message
  986.     lea    pr_TaskNum(a3),a1
  987.     bsr    new_print
  988. .A    bsr    eval_CD
  989.     IFND    DEBUG
  990.     bsr    execscr    
  991.     ENDC
  992. chorus    bsr    CheckForbid    HERE BEGINS THE MAIN LOOP
  993.     bsr    close_redirection
  994.     bsr    raw_on        MAKE SURE RAW MODE IS ON
  995.     clr.b    noreview_flag(a5)
  996.     bsr    compose_prompt
  997.     bsr    get_line
  998.     clr.b    break_flag(a5)
  999.     move.l    4.w,a6
  1000.     moveq    #0,d0        clear signals c&d
  1001.     moveq    #0,d1
  1002.     bset    #SIGBREAKB_CTRL_C,d1
  1003.     bset    #SIGBREAKB_CTRL_D,d1
  1004.     jsr    _LVOSetSignal(a6)
  1005.     move.l    dosbase(a5),a6
  1006.     clr.b    forcediskflag(a5)
  1007.     move.l    parm1(a5),a0
  1008.     move.b    (a0),d0
  1009.     cmp.b    ctrl_codes+15(a5),d0
  1010.     bne.s    .A
  1011.     addq.l    #1,a0
  1012.     tst.b    (a0)
  1013.     bne.s    .B
  1014.     move.l    cdback(a5),d1    dir back
  1015.     jsr    _LVODupLock(a6)
  1016.     move.l    d0,d1
  1017.     bsr    chdir
  1018.     bra.s    chorus
  1019. .B    move.l    a0,parm1(a5)
  1020.     addq.b    #1,forcediskflag(a5)
  1021.     bra    notfound    force disk-command
  1022. .A    cmp.b    #"#",(a0)    #-sign for ;#comment
  1023.     beq    chorus
  1024.     move.l    a0,d7        check for ? (help sign)
  1025.     tst.b    1(a0)
  1026.     bne.s    .C
  1027.     cmp.b    #"?",(a0)
  1028.     bne.s    .C
  1029.     bsr    help_man    ? as command
  1030.     bra    chorus
  1031. .C    lea    comtext(pc),a1
  1032.     lea    comoffs(pc),a2
  1033. mtch    bsr    match
  1034.     tst.l    d0
  1035.     beq.s    notfound
  1036.     move.l    parm1(a5),d7        check for ? (help sign)
  1037.     move.l    parm2(a5),a1
  1038.     tst.b    1(a1)
  1039.     bne.s    .D
  1040.     cmp.b    #"?",(a1)
  1041.     bne.s    .D
  1042.     bsr    rawh_off
  1043.     bsr    help_man    ? as arg
  1044.     bra    chorus
  1045. .D    move.l    sp,errorstack(a5)    important in scripts ?
  1046.     lea    start(pc),a0
  1047. intern    jsr    0(a0,d0.w)    call internal command
  1048.     tst.b    break_flag(a5)
  1049.     bne.s    com_break
  1050. chkfail    move.l    d0,last_failcode(a5)
  1051.     move.l    CLIptr(a5),a0
  1052.     cmp.l    cli_FailLevel(a0),d0    ALL COMMANDS MUST RETURN D0=0 unless failure
  1053.     blo    chorus
  1054. com_fail move.l    d0,-(sp)
  1055.     move.l    #-154,d0
  1056.     bsr    GetMessage        Fail Level
  1057.     move.l    sp,a1
  1058.     bsr    new_print
  1059.     move.l    (sp)+,d0
  1060. com_break clr.b    mult_comm_flag(a5)
  1061.     tst.b    scflag(a5)
  1062.     beq    chorus
  1063.     bsr    kill_script
  1064.     bra    chorus
  1065. notfound bsr    archie3        TRY DISK
  1066.     move.l    d0,-(sp)
  1067.     move.l    thistask(a5),a0
  1068.     move.l    cd_volnode(a5),d0
  1069.     move.l    pr_CurrentDir(a0),a1
  1070.     add.l    a1,a1
  1071.     add.l    a1,a1
  1072.     cmp.l    fl_Volume(a1),d0    check volume node
  1073.     bne.s    .A
  1074.     move.l    cd_block(a5),d0
  1075.     cmp.l    fl_Key(a1),d0    check disk block number
  1076.     beq.s    .B
  1077. .A    bsr    eval_CD        If command changes cd then change prompt.
  1078. .B    move.l    (sp)+,d0
  1079.     bra.s    chkfail
  1080.  
  1081.     
  1082. *Match the string pointed to by A0 to one in a table pted to by a1
  1083. *The number of the matched string is linked to an offset table pted to by
  1084. *A2.  return with 
  1085. *D0 holding offset from 'start' so a jsr 0(a0,d0.w) can be done
  1086. *Entry    A1 pts to Command text table  A2 pts to command offset table
  1087.  
  1088. match    moveq    #0,d1    ;command count
  1089.     move.l    a0,a3    ;save command
  1090. mat2    move.b    (a0)+,d0
  1091.     cmp.b    ctrl_codes+15(a5),d0    ;check "."
  1092.     bne.s    .A
  1093.     tst.b    (a0)
  1094.     beq.s    foundit    ;shortcut
  1095. .A    cmp.b    (a1),d0    ;V1.01
  1096.     beq.s    mat3
  1097.     add.b    #$20,d0    ;'A' -> 'a'    handle commands typed in UCase
  1098.     cmp.b    (a1),d0
  1099.     bne.s    nextcom    ;if any character wrong then check next
  1100. mat3    addq.l    #1,a1
  1101.     tst.b    -1(a0)    ;check whether 0 was last compared
  1102.     beq.s    foundit    ;if it was then success
  1103.     bra.s    mat2
  1104. nextcom    tst.b    (a1)+
  1105.     bne.s    nextcom
  1106.     addq.l    #2,d1    ;each offset is a word
  1107.     move.l    a3,a0
  1108.     tst.b    (a1)    ;put 0,0 at end of com table
  1109.     bne.s    mat2
  1110.     moveq    #0,d0    ;D0 = 0 if command not found
  1111.     rts
  1112. foundit    move.w    0(a2,d1.l),d0    ;get offset
  1113.     rts
  1114.  
  1115.  
  1116. * Subroutine for complet, limiting chars:":","/","""," " *
  1117. cjk1    cmp.b    #":",-1(a1)
  1118.     beq.s    cjke
  1119.     cmp.b    #"/",-1(a1)
  1120.     beq.s    cjke
  1121. cjk2    cmp.b    #$22,-1(a1)
  1122.     beq.s    cjke
  1123.     cmp.b    #" ",-1(a1)
  1124. cjke    rts
  1125.  
  1126. * Complete Filename in Shelline *
  1127. * a2 points to part of filename, d6 length of part *
  1128. * d4: linmax , d5:linhere *
  1129. complet    clr.b    temp2buf(a5)
  1130.     lea    shelline(a5),a1
  1131.     move.l    a1,a0
  1132.     move.l    d5,d6
  1133.     beq.s    .B
  1134.     add.l    d5,a1
  1135.     bsr    cjk1
  1136.     beq.s    .B        ;.C
  1137. .A    subq.l    #1,a1        look for begin of filename
  1138.     cmp.l    a1,a0
  1139.     beq.s    .B    
  1140.     bsr    cjk1
  1141.     bne.s    .A
  1142. .B    move.l    a1,a2        filename-pos. in a2
  1143.     sub.l    a0,a1
  1144.     sub.l    a1,d6        length in d6
  1145.     move.b    (a2),d3        save char
  1146.     clr.b    (a2)        null-end pathname
  1147.     move.l    a2,a1
  1148.     bra.s    .F
  1149. .D    subq.l    #1,a1        look for begin of path
  1150. .F    cmp.l    a1,a0
  1151.     beq.s    .E
  1152.     bsr    cjk2
  1153.     bne.s    .D
  1154. .E    move.l    a1,d1
  1155.     moveq    #-2,d2
  1156.     jsr    _LVOLock(a6)    lock path
  1157.     move.b    d3,(a2)        replace null-char by old one
  1158.     move.l    d0,d7        save lock
  1159.     beq.s    .C
  1160.     bsr    fibexam2
  1161.     moveq    #0,d3
  1162.     tst.l    fib_DirEntryType(a5)
  1163.     bpl.s    wdhcpl        if plus,is directory
  1164. .G    move.l    d7,d1
  1165.     jsr    _LVOUnLock(a6)
  1166. .C    rts            an error occured
  1167. wdhcpl    bsr    fibexnx        repeat to search whole dir
  1168.     tst.l    d0        next filename or dirname
  1169.     beq    endcpl
  1170.     lea    fib_FileName(a5),a0
  1171.     move.l    a0,a3
  1172.     lea    ignoreit(a5),a1
  1173.     tst.b    (a1)
  1174.     beq.s    .F
  1175.     bsr    wildmatch        wildcheck
  1176.     tst.b    d0
  1177.     beq.s    wdhcpl
  1178. .F    move.l    a3,a0
  1179.     move.l    a2,a1
  1180.     move.l    d6,d2
  1181.     bra.s    .I
  1182. .A    move.b    (a0)+,d0
  1183.     move.b    (a1)+,d1
  1184.     bsr    compD1D0nocase        does it fit ?
  1185.     bne.s    wdhcpl
  1186. .I    dbra    d2,.A
  1187.     lea    temp2buf(a5),a0
  1188.     tst.l    d3
  1189.     bne.s    .B
  1190. .C    move.b    (a3)+,(a0)+    ! first time: copy filename !
  1191.     bne.s    .C
  1192.     move.b    #" ",-1(a0)    add a space at the end (files)
  1193.     clr.b    (a0)
  1194.     tst.l    fib_DirEntryType(a5)
  1195.     bmi.s    .E        if plus,is directory
  1196.     move.b    #"/",-1(a0)    add a / at the end (dirs)
  1197. .E    moveq    #1,d3
  1198.     bra.s    wdhcpl
  1199.  
  1200. .B    btst    #FLmatch,Flags+3(a5)    ! next time !
  1201.     beq.s    .G
  1202.     tst.l    d3
  1203.     bmi.s    .G
  1204.     moveq    #-1,d3
  1205.     lea    hide_cursor(pc),a1
  1206.     bsr    pr_stringlf    print first time
  1207.     lea    temp2buf(a5),a1
  1208.     bsr    pr_string
  1209.     bsr    pr_space
  1210. .G    move.b    (a0)+,d0
  1211.     move.b    (a3)+,d1
  1212.     bsr    compD1D0nocase    next time: find longest common part
  1213.     bne.s    .D
  1214.     tst.b    -1(a0)
  1215.     beq.s    .D
  1216.     tst.b    -1(a3)
  1217.     bne.s    .G
  1218. .D    clr.b    -1(a0)
  1219.     btst    #FLmatch,Flags+3(a5)
  1220.     beq    wdhcpl
  1221.     lea    fib_FileName(a5),a1
  1222.     lea    tempbuf(a5),a0
  1223. .J    move.b    (a1)+,(a0)+
  1224.     bne.s    .J
  1225.     move.b    #" ",-1(a0)
  1226.     tst.l    fib_DirEntryType(a5)
  1227.     bmi.s    .H        if plus,is directory
  1228.     move.b    #"/",-1(a0)
  1229. .H    move.b    #" ",(a0)+
  1230.     clr.b    (a0)
  1231.     lea    tempbuf(a5),a1
  1232.     bsr    pr_string    print other times
  1233.     bra    wdhcpl        repeat with all filenames
  1234.  
  1235. endcpl    move.l    d7,d1
  1236.     jsr    _LVOUnLock(a6)
  1237.     btst    #FLmatch,Flags+3(a5)
  1238.     beq    .I
  1239.     tst.l    d3        next time
  1240.     bpl.s    .I
  1241.     lea    show_cursor(pc),a1
  1242.     bsr    pr_stringlf
  1243. .I    lea    temp2buf(a5),a1
  1244.     move.l    d6,d2
  1245.     bra    print_def2
  1246.  
  1247. DisplayBeep
  1248.     move.l    intuibase(a5),a6
  1249.     suba.l    a0,a0
  1250.     jsr    _LVODisplayBeep(a6)
  1251.     move.l    dosbase(a5),a6
  1252.     rts
  1253.  
  1254.  
  1255. get_one_char
  1256.     bsr    clearArgs
  1257.     move.l    inhandle(a5),myArg1(a5)
  1258.     lea    tempbytes(a5),a0
  1259.     move.l    a0,myArg2(a5)
  1260.     moveq    #1,d0
  1261.     move.l    d0,myArg3(a5)
  1262.     move.l    thistask(a5),a0
  1263.     move.l    pr_ConsoleTask(a0),packettask(a5)
  1264.     moveq    #ACTION_READ,d0
  1265.     move.l    d0,packettype(A5)
  1266.     bsr    sendpacket2    read keyboard with packets
  1267.     moveq    #0,d3
  1268.     move.l    thistask(a5),a0
  1269.     move.b    pr_MsgPort+MP_SIGBIT(a0),d1
  1270.     bset    d1,d3        set wait bit for reading
  1271.     move.l    appwinport(a5),d2
  1272.     beq.s    .A
  1273.     move.l    d2,a0
  1274.     move.b    MP_SIGBIT(a0),d1
  1275.     bset    d1,d3        set wait bit for appwindow
  1276. .A    move.l    d3,d0
  1277.     jsr    _LVOWait(a6)    wait for anything
  1278.     tst.l    d2
  1279.     beq.s    .B
  1280.     move.l    d2,a0
  1281.     jsr    _LVOGetMsg(a6)    try to get appwinmsg
  1282.     tst.l    d0
  1283.     beq.s    .B
  1284.     move.l    d0,a2
  1285.     bsr    ProcessApp    look at it
  1286.     move.l    a2,a1
  1287.     jsr    _LVOReplyMsg(a6)
  1288.     move.l    dosbase(a5),a6
  1289.     lea    tempbuf(a5),a1
  1290.     move.l    d2,-(sp)
  1291.     bsr    print_def    write iconname to shelline
  1292.     move.l    (sp)+,d2
  1293.     move.l    intuibase(a5),a6
  1294.     move.l    windowptr(a5),d0
  1295.     bmi.s    .C
  1296.     beq.s    .C
  1297.     move.l    d0,a0
  1298.     jsr    _LVOActivateWindow(a6)
  1299. .C    move.l    4.w,a6
  1300.  
  1301. .B    move.l    thistask(a5),a0
  1302.     lea    pr_MsgPort(a0),a0
  1303.     jsr    _LVOGetMsg(a6)    try to get read-packet-reply
  1304.     move.l    d0,d1
  1305.     beq.s    .A
  1306.     move.l    dosbase(a5),a6
  1307.     lea    sp_node(a5),a0
  1308.     move.l    #212,d0
  1309.     cmp.l    d1,a0
  1310.     bne    pr_galactic    got wrong dospacket
  1311.     tst.l    sp_res1(a5)
  1312.     bmi.s    .D        error occured
  1313.     beq.s    .D
  1314.     move.b    tempbytes(a5),d6
  1315.     rts
  1316. .D    moveq    #20,d1
  1317.     bsr    GuruIt
  1318.     bra    cloga
  1319.  
  1320. saveundo
  1321.     lea    shelline(a5),a0
  1322.     lea    CLIbuf(a5),a1
  1323.     move.l    d4,d0
  1324.     bra.s    .B
  1325. .A    move.b    (a0)+,(a1)+
  1326. .B    dbra    d0,.A
  1327.     clr.b    (a1)
  1328.     rts
  1329.  
  1330. * A1 pts to past, d0=nost
  1331. gimme    lea    shelline(a5),a2
  1332.     move.l    d0,nost(a5)
  1333.     cmp.l    now(a5),d0
  1334.     bne.s    .C
  1335.     moveq    #-1,d4        reset linmax
  1336.     lea    CLIbuf(a5),a0
  1337. .D    addq.l    #1,d4
  1338.     move.b    (a0)+,(a2)+    copy undo to shelline
  1339.     bne.s    .D
  1340.     move.l    d4,d5        linmax=linhere
  1341.     bra    gimme3
  1342.  
  1343. .C    moveq    #0,d5        linhere = 0
  1344. .B    addq.l    #1,d0        copy to shelline
  1345.     and.l    #HISTORY_SIZE-1,d0
  1346.     cmp.b    #LF,0(a1,d0.l)
  1347.     beq.s    .A
  1348.     move.b    0(a1,d0.l),0(a2,d5.l)
  1349.     addq.l    #1,d5
  1350.     bra.s    .B
  1351. .A    move.l    d5,d4        linhere=linmax
  1352.  
  1353. gimme3    lea    shelline(a5),a2        Print input line newer
  1354.     lea    delete_line(pc),a1
  1355.     bsr    pr_string
  1356.     move.l    prompt_cr(a5),a1
  1357.     bsr    pr_string
  1358.     clr.b    0(a2,d4.l)    clear last
  1359.     move.l    a2,a1
  1360.     bsr    pr_string
  1361. restore_cursor
  1362.     move.l    d4,d0
  1363.     sub.l    d5,d0
  1364.     beq.s    .A
  1365.     bpl.s    cursor_left
  1366. .A    rts
  1367. cursor_left    ;move cursor d0 chars left
  1368.     lea    tempbuf(a5),a1
  1369.     move.l    a1,a0
  1370.     bra.s    .E
  1371. .F    move.w    #$9b<<8+"D",(a0)+    left cursor
  1372. .E    dbra    d0,.F        
  1373.     clr.b    (a0)
  1374.     bra    pr_string    restore cursorpos
  1375.  
  1376. cursor_right
  1377.     lea    tempbuf(a5),a1
  1378.     move.l    a1,a0
  1379.     bra.s    .A
  1380. .B    move.w    #$9b<<8+"C",(a0)+    right cursor
  1381. .A    dbra    d0,.B
  1382.     clr.b    (a0)
  1383.     bra    pr_string
  1384.  
  1385. * READ TEXT LINE from keyboard or script into buffer pointed to by a0,
  1386. * and clear last byte. NOTE A0 is essentially ignored, and shelline is the
  1387. * assumed address. Return with a0 same, and d0=length of text read
  1388. type_in    tst.b    scflag(a5)        ;check whether we're doing a script
  1389.     bne    scr_in
  1390. type_in2
  1391.     move.l    a0,-(sp)
  1392.     tst.l    ConsoleSwitch(a5)
  1393.     bne.s    .A
  1394.     move.l    a0,a2            use console in cooked mode
  1395. .C    move.l    a2,d2
  1396.     move.l    inhandle(a5),d1
  1397.     beq    cloga
  1398.     move.l    #SHELLINE_SIZE,d3
  1399.     jsr    _LVORead(a6)
  1400.     tst.l    d0
  1401.     bmi    cloga
  1402.     beq    cloga
  1403.     clr.b    0(a2,d0.l)
  1404.     cmp.b    #LF,-1(a2,d0.l)
  1405.     bne.s    .C
  1406.     cmp.b    #LF,(a2)
  1407.     bne.s    .B
  1408.     bsr    pr_prompt
  1409.     bra.s    .C
  1410. .B    move.l    (sp)+,a0
  1411.     rts
  1412.     
  1413. .A    clr.b    CLIbuf(a5)    (for undo)
  1414.     moveq    #0,d5        D5=linhere    use console in raw mode
  1415.     moveq    #0,d4        D4=linmax
  1416. next_ch    bsr    get_one_char
  1417.     cmp.b    #$9b,d6
  1418.     bne    not_csi
  1419.     clr.l    gather_ptr(a5)
  1420. fetch_csi    bsr    get_one_char
  1421.     lea    gather(a5),a0
  1422.     move.l    gather_ptr(a5),d0
  1423.     move.b    d6,0(a0,d0.l)        ;save byte from CSI sequence.
  1424.     addq.l    #1,gather_ptr(a5)
  1425.     moveq    #40,d1
  1426.     cmp.l    d1,d0
  1427.     blo.s    .A
  1428.     clr.l    gather_ptr(a5)
  1429. .A    cmp.b    #'@',d6
  1430.     blo.s    fetch_csi        ;keep gathering if char < @
  1431.     cmp.b    #'~',d6
  1432.     bhi.s    fetch_csi        ;keep gathering if char > ~
  1433.  
  1434.     cmp.b    #"|",d6        CHECK CLOSE GADGET
  1435.     bne.s    not_cloga
  1436. cloga2    btst    #FLappicon,Flags+3(a5)
  1437.     beq.s    cloga        exit immediately
  1438.     tst.b    openwin_flag(a5)
  1439.     beq.s    cloga
  1440.     bsr    WaitAppIcon
  1441.     addq.b    #1,noreview_flag(a5)
  1442.     bsr    raw_on
  1443. gimme3next
  1444.     bsr    gimme3
  1445.     bra.s    next_ch
  1446.  
  1447. cloga    move.l    dosbase(a5),a6    totally-exit-routine
  1448.     move.l    errorstack(a5),sp    ;kill return address on stack
  1449.     bsr    raw_off
  1450.     moveq    #-1,d7
  1451.     tst.b    scflag(a5)
  1452.     beq.s    .A
  1453.     bsr    kill_script
  1454. .A    rts
  1455.  
  1456. not_cloga
  1457.     cmp.b    #'D',d6        CHECK LEFT ARROW    <CSI>D
  1458.     bne.s    not_left
  1459.     tst.l    d5
  1460.     beq.s    not_left
  1461.     subq.l    #1,d5
  1462.     moveq    #1,d0
  1463.     bsr    cursor_left
  1464.     bra    next_ch
  1465.     
  1466. not_left    cmp.b    #'Z',d6    CHECK TAB & SHIFT    <CSI> Z
  1467.     bne.s    not_tab_left
  1468. v_buffer
  1469.     tst.l    ReviewSize(a5)
  1470.     beq    next_ch
  1471.     movem.l    d3-d7/a2-a4,-(sp)
  1472.     sub.l    a3,a3
  1473.     bsr    viewbuffer
  1474.     movem.l    (sp)+,d3-d7/a2-a4
  1475.     addq.b    #1,noreview_flag(a5)
  1476.     bra.s    gimme3next
  1477.  
  1478. not_tab_left    cmp.b    #'A',d6
  1479.     bne.s    not_sh_left
  1480.     cmp.b    #' ',gather(a5)    CHECK SHIFT LEFT ARROW    <CSI> A
  1481.     bne.s    not_sh_left
  1482.     move.l    d5,d0
  1483.     bsr    cursor_left
  1484.     moveq    #0,d5
  1485.     bra    next_ch
  1486.  
  1487. not_sh_left
  1488.     cmp.b    #'C',d6        CHECK RIGHT ARROW    <CSI>C
  1489.     bne.s    not_right
  1490.     cmp.l    d4,d5
  1491.     bhs.s    not_right
  1492.     addq.l    #1,d5
  1493.     moveq    #1,d0
  1494.     bsr    cursor_right
  1495.     bra    next_ch
  1496.  
  1497. not_right    cmp.b    #'@',d6
  1498.     bne.s    not_sh_right
  1499.     cmp.b    #' ',gather(a5)    CHECK SHIFT RIGHT ARROW    <CSI> @
  1500.     bne.s    not_sh_right
  1501.     move.l    d4,d0
  1502.     sub.l    d5,d0
  1503.     bsr    cursor_right
  1504.     move.l    d4,d5
  1505.     bra    next_ch
  1506.  
  1507. not_sh_right
  1508.     cmp.b    #'A',d6        CHECK UP ARROW
  1509.     bne.s    not_up
  1510.     lea    past(a5),a1
  1511.     move.l    nost(a5),d0
  1512.     cmp.l    then(a5),d0
  1513.     beq.s    .B
  1514. .A    subq.l    #1,d0
  1515.     and.l    #HISTORY_SIZE-1,d0        WRAP AROUND
  1516.     cmp.b    #LF,0(a1,d0.l)
  1517.     bne.s    .A
  1518. .B    bsr    gimme
  1519.     bra    next_ch
  1520.  
  1521. not_up    cmp.b    #'B',d6        CHECK DOWN ARROW
  1522.     bne.s    not_down
  1523. up_bit    lea    past(a5),a1    CALLED BY SHIFT DOWN BIT
  1524.     move.l    nost(a5),d0
  1525.     cmp.l    now(a5),d0
  1526.     beq.s    .B
  1527. .A    addq.l    #1,d0
  1528.     and.l    #HISTORY_SIZE-1,d0
  1529.     cmp.b    #LF,0(a1,d0.l)
  1530.     bne.s    .A
  1531. .B    bsr    gimme
  1532.     bra    next_ch
  1533.  
  1534. not_down    cmp.b    #'T',d6        CHECK SHIFT UP
  1535.     bne    not_sh_up
  1536.     lea    past(a5),a1
  1537.     tst.l    d5
  1538.     bne.s    search_his
  1539.     move.l    then(a5),nost(a5)    nost = then (the top)
  1540.     move.l    nost(a5),d0
  1541.     bsr    gimme
  1542.     bra    next_ch
  1543. search_his            ;search shelline in history    V2.0
  1544.     move.l    nost(a5),d0
  1545. .C    cmp.l    then(a5),d0
  1546.     bne.s    .A
  1547.     move.l    nost(a5),d0
  1548.     bra.s    end_seh
  1549. .A    subq.l    #1,d0
  1550.     and.l    #HISTORY_SIZE-1,d0
  1551.     cmp.b    #LF,0(a1,d0.l)
  1552.     bne.s    .A
  1553.  
  1554.     lea    shelline(a5),a0
  1555.     move.l    d5,d1
  1556.     subq.l    #1,d1
  1557.     move.l    d0,d2
  1558. .D    addq.l    #1,d2
  1559.     and.l    #HISTORY_SIZE-1,d2
  1560.     movem.l    d0/d1,-(sp)
  1561.     move.b    0(a1,d2.l),d0
  1562.     move.b    (a0),d1
  1563.     bsr    compD1D0nocase
  1564.     movem.l    (sp)+,d0/d1
  1565.     bne.s    .C
  1566.     addq.l    #1,a0
  1567.     dbra    d1,.D
  1568. end_seh    move.l    d5,d2        save d5
  1569.     bsr    gimme
  1570.     move.l    d2,d5
  1571.     bsr    restore_cursor
  1572.     bra    next_ch
  1573.  
  1574.  
  1575. not_sh_up    cmp.b    #'S',d6        CHECK SHIFT DOWN
  1576.     bne.s    not_sh_down
  1577.     move.l    now(a5),nost(a5)    nost = now (the bottom)
  1578.     bra    up_bit
  1579.     
  1580. not_sh_down            ;NOTE V1.05
  1581.     cmp.b    #'~',d6        CHECK FUNCTION KEYS AND HELP KEY
  1582.     bne    next_ch
  1583.     cmp.b    #'?',gather(a5)
  1584.     bne.s    process_the_func_key
  1585.     lea    help_ret(pc),a1
  1586.     bsr    print_def    will rip last address off stack
  1587. * never gets to this line
  1588. process_the_func_key
  1589.     bsr    translate_func_key
  1590.     bra    next_ch
  1591.         
  1592. * Was not a CSI code
  1593. not_csi    cmp.b    ctrl_codes+6(a5),d6        CHECK ESCAPE (ctrl+[)
  1594.     beq    cloga2        exit immediately
  1595.  
  1596. not_esc    cmp.b    ctrl_codes+7(a5),d6    CHECK TAB (ctrl+I)
  1597.     bne.s    not_tab_right
  1598.     moveq    #0,d0
  1599. .A    cmp.l    d4,d5
  1600.     bhs.s    .B
  1601.     addq.l    #1,d5
  1602.     addq.l    #1,d0
  1603.     lea    shelline-1(a5),a0
  1604.     bsr    tab_check
  1605.     bne.s    .A
  1606. .B    bsr    cursor_right
  1607.     bra    next_ch
  1608.     
  1609. not_tab_right
  1610.     cmp.b    ctrl_codes+8(a5),d6        CHECK CTRL Y
  1611.     beq    v_buffer        same as shift&tab
  1612.  
  1613.     cmp.b    ctrl_codes+9(a5),d6        CHECK BACKSPACE (ctrl+H)
  1614.     bne.s    not_bs
  1615.     tst.l    d5
  1616.     beq.s    not_bs
  1617.     subq.l    #1,d5
  1618.     lea    backspace_it(pc),a1
  1619.     bsr    pr_string
  1620.     bsr    del_str
  1621.     bsr    saveundo
  1622.     bra    next_ch
  1623.  
  1624. del_str    lea    shelline(a5),a4
  1625.     lea    SHELLINE_SIZE+shelline(a5),a1    NOTE SHELLINE SIZE!!!
  1626.     lea    0(a4,d5.w),a0
  1627.     lea    1(a0),a2
  1628. .A    move.b    (a2)+,(a0)+
  1629.     cmp.l    a2,a1
  1630.     bne.s    .A
  1631.     subq.l    #1,d4
  1632.     rts
  1633.  
  1634. not_bs    cmp.b    #$7f,d6                CHECK DELETE
  1635.     bne.s    not_del
  1636.     cmp.l    d4,d5
  1637.     bhs.s    not_del
  1638.     lea    delete_it(pc),a1
  1639.     bsr    pr_string
  1640.     bsr    del_str
  1641.     bsr    saveundo
  1642.     bra    next_ch
  1643.     
  1644. not_del    cmp.b    ctrl_codes+5(a5),d6        CHECK CTRL X
  1645.     bne.s    not_ctrlx
  1646.     bsr    saveundo
  1647.     moveq    #0,d5        delete shelline
  1648.     moveq    #0,d4
  1649.     bra    gimme3next
  1650.     
  1651. not_ctrlx
  1652.     cmp.b    ctrl_codes+3(a5),d6        CHECK CTRL E
  1653.     bne.s    not_ctrle
  1654. .A    cmp.l    d4,d5        delete to end of line
  1655.     bhs.s    .B
  1656.     lea    delete_it(pc),a1
  1657.     bsr    pr_string
  1658.     bsr    del_str
  1659.     bra.s    .A
  1660. .B    bsr    saveundo
  1661.     bra    next_ch
  1662.     
  1663. not_ctrle
  1664.     cmp.b    ctrl_codes+2(a5),d6        CHECK CTRL S
  1665.     bne.s    not_ctrls
  1666. .A    tst.l    d5        delete to start of line
  1667.     beq.s    .B
  1668.     subq.l    #1,d5
  1669.     lea    backspace_it(pc),a1
  1670.     bsr    pr_string
  1671.     bsr    del_str
  1672.     bra.s    .A
  1673. .B    bsr    saveundo
  1674.     bra    next_ch
  1675.     
  1676. not_ctrls
  1677.     cmp.b    ctrl_codes+1(a5),d6        CHECK CTRL W
  1678.     bne.s    not_ctrlw
  1679. .A    tst.l    d5        delete last word
  1680.     beq.s    .B
  1681.     subq.l    #1,d5
  1682.     lea    backspace_it(pc),a1
  1683.     bsr    pr_string
  1684.     bsr    del_str
  1685.     lea    shelline-1(a5),a0
  1686.     bsr    tab_check
  1687.     bne.s    .A
  1688.     bsr    saveundo
  1689. .B    bra    next_ch
  1690.  
  1691. not_ctrlw
  1692.     cmp.b    ctrl_codes+0(a5),d6        CHECK CTRL Q
  1693.     bne.s    not_ctrlq
  1694. .A    cmp.l    d4,d5        delete next word
  1695.     bhs.s    .B
  1696.     lea    delete_it(pc),a1
  1697.     bsr    pr_string
  1698.     bsr    del_str
  1699.     lea    shelline+0(a5),a0
  1700.     bsr    tab_check
  1701.     bne.s    .A
  1702.     bsr    saveundo
  1703. .B    bra    next_ch
  1704.  
  1705. not_ctrlq
  1706.     cmp.b    ctrl_codes+4(a5),d6        CHECK CTRL A
  1707.     bne.s    not_ctrla
  1708.     movem.l    d3/d6/d7/a3,-(sp)
  1709.     bsr    complet        complete filename
  1710.     movem.l    (sp)+,d3/d6/d7/a3
  1711.     bsr    saveundo
  1712.     bra    next_ch
  1713.  
  1714. not_ctrla
  1715.     cmp.b    ctrl_codes+10(a5),d6        CHECK CTRL J
  1716.     bne.s    not_ctrlj
  1717.     bsr    do_cr2
  1718.     move.l    errorstack(a5),sp
  1719.     bra    chorus
  1720.  
  1721. not_ctrlj
  1722.     cmp.b    ctrl_codes+12(a5),d6        CHECK CTRL L
  1723.     bne.s    not_ctrll
  1724.     lea    clrtx(pc),a1
  1725.     bsr    pr_string    clear window
  1726.     bra    gimme3next
  1727.  
  1728. not_ctrll
  1729.     cmp.b    ctrl_codes+13(a5),d6        CHECK CTRL R
  1730.     bne.s    not_ctrlr
  1731.     moveq    #0,d0
  1732. tab_left tst.l    d5
  1733.     beq.s    .B
  1734.     subq.l    #1,d5
  1735.     addq.l    #1,d0
  1736.     lea    shelline-1(a5),a0
  1737.     bsr    tab_check
  1738.     bne.s    tab_left
  1739. .B    bsr    cursor_left
  1740.     bra    next_ch
  1741.  
  1742. tab_check cmp.b    #' ',(a0,d5.w) words are separated by / . : or space
  1743.     beq.s    .A
  1744.     cmp.b    #':',(a0,d5.w)
  1745.     beq.s    .A
  1746.     cmp.b    #'.',(a0,d5.w)
  1747.     beq.s    .A
  1748.     cmp.b    #'/',(a0,d5.w)
  1749. .A    rts
  1750.  
  1751. not_ctrlr
  1752.     cmp.b    ctrl_codes+14(a5),d6        CHECK CTRL V
  1753.     bne.s    not_ctrlv
  1754.     movem.l    d3-d7/a2-a4,-(sp)
  1755.     lea    past(a5),a2
  1756.     move.l    now(a5),d3
  1757.     move.l    #HISTORY_SIZE,d2
  1758.     sub.l    a3,a3
  1759.     bsr    viewhist
  1760.     movem.l    (sp)+,d3-d7/a2-a4
  1761.     addq.b    #1,noreview_flag(a5)
  1762.     bra    gimme3next
  1763.  
  1764. not_ctrlv
  1765.     cmp.b    #6,d6                CHECK CTRL F
  1766.     bne.s    not_ctrlf
  1767.     move.l    4.w,a6        Display Filerequester
  1768.     lea    aslname(pc),a1
  1769.     jsr    _LVOOldOpenLibrary(a6)
  1770.     tst.l    d0
  1771.     beq.s    .A
  1772.     move.l    d0,a6
  1773.     jsr    _LVOAllocFileRequest(a6)
  1774.     move.l    d0,d2
  1775.     beq.s    .B
  1776.     move.l    d2,a0
  1777.     jsr    _LVORequestFile(a6)
  1778.     tst.l    d0
  1779.     beq.s    .C
  1780.     move.l    d2,a0
  1781.     move.l    rf_File(a0),a1
  1782.     move.l    rf_Dir(a0),a0
  1783.     lea    tempbuf(a5),a2
  1784.     bsr    addpath
  1785.     move.l    a2,a1
  1786.     bsr    print_def
  1787. .C    move.l    d2,a0
  1788.     jsr    _LVOFreeFileRequest(a6)
  1789. .B    move.l    a6,a1
  1790.     move.l    4.w,a6
  1791.     jsr    _LVOCloseLibrary(a6)
  1792. .A    move.l    dosbase(a5),a6
  1793.     bra    gimme3next
  1794.  
  1795. not_ctrlf
  1796.     cmp.b    ctrl_codes+11(a5),d6        CHECK CTRL M
  1797.     beq.s    do_cr
  1798.     cmp.b    #13,d6        CHECK CR
  1799.     beq    do_cr
  1800. no_cr    cmp.b    #" ",d6    
  1801.     blo.s    .A
  1802.     bsr    ins_char
  1803.     bsr    saveundo
  1804. .A    bra    next_ch
  1805.  
  1806. do_cr    move.l    (sp)+,a2
  1807. do_cr2    lea    return_it(pc),a1
  1808.     bsr    pr_string
  1809.     lea    shelline(a5),a4
  1810.     move.b    #LF,0(a4,d4.w)    HACK JOB    (MUST END IN LF 0)
  1811.     clr.b    1(a4,d4.w)    FOR ALIAS STUFF
  1812.     tst.l    d4        CHECK IF NOTHING TYPED
  1813.     bne.s    history_it
  1814.     bsr    pr_prompt        IF JUST HIT RETURN, THEN START AGAIN
  1815.     move.l    a2,a0
  1816.     bra    type_in2
  1817. history_it
  1818.     lea    past(a5),a1    CHECK IF LAST ENTRY IS SAME AS CURRENT
  1819.     move.l    now(a5),d0
  1820.     cmp.l    then(a5),d0
  1821.     beq.s    .B
  1822.     move.l    d0,nost(a5)
  1823. .A    subq.l    #1,d0        FIND LAST
  1824.     and.l    #HISTORY_SIZE-1,d0    WRAP AROUND
  1825.     cmp.b    #LF,0(a1,d0.l)
  1826.     bne.s    .A
  1827.     lea    (a4),a0
  1828.     bra.s    .C
  1829. .D    cmp.b    #LF,d1        COMPARE LAST TO SHELLINE
  1830.     beq    finland
  1831. .C    addq.l    #1,d0
  1832.     and.l    #HISTORY_SIZE-1,d0
  1833.     move.b    (a0)+,d1
  1834.     cmp.b    0(a1,d0.l),d1
  1835.     beq.s    .D
  1836.  
  1837. .B    move.l    a4,a3    lin    COPY LINE TO HISTORY  BUFFER
  1838.     move.l    now(a5),d3    pts to the last LF
  1839.  
  1840. .E    addq.l    #1,d3
  1841.     and.l    #HISTORY_SIZE-1,d3        WRAP AROUND
  1842.     move.b    (a3)+,d0
  1843.     move.b    d0,0(a1,d3.l)
  1844.     cmp.b    #LF,d0
  1845.     bne.s    .E
  1846. ;dumped_hist
  1847.     move.l    d3,nost(a5)    nost = now
  1848.     move.l    d3,now(a5)
  1849.     move.l    then(a5),d1
  1850.     cmp.b    #LF,0(a1,d1.l)
  1851.     bne.s    .G    BRANCH IF WRAPPED AROUND
  1852.     cmp.l    d3,d1
  1853.     bne.s    finland    BRANCH IF THEN = (10) & THEN <> NOW
  1854. .G    
  1855. *    move.l    d3,then(a5)    then=now
  1856. .H    addq.l    #1,d3    SEARCH FOR NEXT LF (NEW TOP OF HISTORY)
  1857.     and.l    #HISTORY_SIZE-1,d3        WRAP AROUND
  1858.     move.b    0(a1,d3.l),d0
  1859.     cmp.b    #LF,d0
  1860.     bne.s    .H        ***
  1861.     move.l    d3,then(a5) SET NEW THEN (TOP OF HISTORY)
  1862.  
  1863. ******* 
  1864. finland    tst.b    scflag(a5)
  1865.     bne.s    .D
  1866.     lea    prompt_string(a5),a1    write to review-buffer
  1867.     move.l    a1,d2
  1868.     moveq    #-1,d3
  1869. .E    addq.l    #1,d3
  1870.     tst.b    (a1)+
  1871.     bne.s    .E
  1872.     bsr    toreview
  1873.     move.l    a2,d2
  1874.     move.l    d4,d3
  1875.     addq.l    #1,d3
  1876.     bsr    toreview
  1877. .D    move.l    a2,a0
  1878.     move.l    d4,d0
  1879.     rts
  1880.  
  1881. * insert a char in the shelline
  1882. ins_char cmp.w    #SHELLINE_SIZE-2,d4    make sure line is not too long
  1883.     bhs    DisplayBeep
  1884.     lea    tempbuf(a5),a1
  1885.     move.w    #$9b<<8+"@",(a1)
  1886.     clr.b    3(a1)
  1887.     move.b    d6,2(a1)    shove printable char after insert seq
  1888.     bsr    pr_string        insert space for char
  1889.     lea    shelline(a5),a1    ethel
  1890.     lea    1(a1,d4.w),a0    linmax
  1891.     lea    1(a0),a2        A2=linmax+1
  1892.     lea    0(a1,d5.w),a1    linhere
  1893. .A    move.b    -(a0),-(a2)    insert char into shelline
  1894.     cmp.l    a0,a1
  1895.     bne.s    .A
  1896.     lea    shelline(a5),a4
  1897.     move.b    d6,0(a4,d5.w)
  1898.     addq.l    #1,d5
  1899.     addq.l    #1,d4
  1900. .B    rts
  1901.  
  1902. * TRANSLATE FUNC CODE TO F1,F2 ETC AND SET UP POINTERS
  1903. translate_func_key
  1904.     lea    gather(a5),a0
  1905.     move.l    gather_ptr(a5),d0
  1906.     cmp.b    #3,d0        CHECK IF TWO CODES EG '12'
  1907.     beq    process_shift_func
  1908. unshifted_func_key
  1909.     cmp.b    #2,d0
  1910.     bne    translate_func_fail
  1911.     move.b    (A0),d0
  1912.     moveq    #'f',d1
  1913. act_sh    bsr    convert_to_set_name
  1914.     bsr    search_sets    returns D0 pointer to set
  1915. *d0=set ptr
  1916. *print_func_defn
  1917.     tst.l    d0
  1918.     beq.s    do_not_print_func
  1919.     move.l    d0,a1
  1920.     lea    set_defn(a1),a1
  1921. print_def    ;insert string in a1 into shelline
  1922.     moveq    #0,d2
  1923. print_def2    ;for FNC, d2=number of chars before
  1924.     moveq    #-1,d1
  1925. .G    addq.l    #1,d1        D1=length
  1926.     tst.b    (a1)+
  1927.     bne.s    .G
  1928.     sub.l    d2,d1
  1929.     bmi    DisplayBeep
  1930.     subq.l    #1,a1        for later
  1931.     move.l    d4,d0
  1932.     add.l    d1,d0
  1933.     cmp.w    #SHELLINE_SIZE-2,d0    make sure line is not too long
  1934.     bhs    DisplayBeep
  1935.     movem.l    a2-a3,-(sp)
  1936.     lea    shelline(a5),a0    ethel
  1937.     lea    1(a0,d4.w),a3    A3=linmax
  1938.     move.l    a3,a2
  1939.     add.l    d1,a2        A2=linmax+length
  1940.     lea    0(a0,d5.w),a0    linhere
  1941. .A    move.b    -(a3),-(a2)    insert chars into shelline
  1942.     cmp.l    a3,a0
  1943.     bne.s    .A
  1944.     move.l    d1,d0
  1945.     add.l    d2,d0
  1946.     bra.s    .C
  1947. .D    move.b    -(a1),-(a2)    copy found filename
  1948. .C    dbra    d0,.D
  1949.     movem.l    (sp)+,a2-a3
  1950.     add.l    d1,d5
  1951.     add.l    d1,d4
  1952.  
  1953.     lea    shelline(a5),a0
  1954.     cmp.b    #'M',-1(a0,d5.l)    check for auto return ^M
  1955.     bne.s    .F
  1956.     cmp.b    #'^',-2(a0,d5.l)
  1957.     bne.s    .F
  1958.     subq.l    #2,d5
  1959.     move.l    d5,d4
  1960.     bsr    gimme3        print it
  1961.     addq.l    #4,sp        get rid of last return address
  1962.     bra    do_cr        do a carriage return
  1963. .F    bsr    gimme3        print shelline
  1964. do_not_print_func
  1965.     rts
  1966.  
  1967. process_shift_func
  1968.     move.b    1(A0),d0
  1969.     moveq    #'F',d1
  1970.     bra    act_sh
  1971. translate_func_fail
  1972.     rts
  1973.  
  1974.  
  1975. convert_to_set_name
  1976.     lea    temp2buf(a5),a1
  1977.     move.b    d1,(a1)+
  1978.     addq.b    #1,d0
  1979.     move.b    d0,(a1)+
  1980.     cmp.b    #':',d0
  1981.     bne    not_func10
  1982.     move.b    #'1',-1(a1)
  1983.     move.b    #'0',(a1)+
  1984. not_func10
  1985.     clr.b    (a1)
  1986.     rts
  1987.  
  1988. search_sets
  1989. * uses temp2buf, EXIT: D0 ptr to the associated set. D1 pts to prior set
  1990. * RETURN D0=0 IF NOT FOUND.
  1991.     movem.l    d2-d4/a1-a2,-(sp)
  1992.     lea    temp2buf(a5),a1
  1993.     move.l    a1,d2
  1994.     lea    first_set_defn(a5),a2
  1995.     move.l    a2,d4        NOTE PRIOR SET 
  1996.     move.l    (a2),d3
  1997. search_next_set
  1998.     beq    .B
  1999.     move.l    d3,a2
  2000.     lea    set_name(a2),a2    A2=current set name
  2001.     move.l    d2,a1        A1=name to match
  2002.     bra.s    .C
  2003. .A    tst.b    d0
  2004.     beq.s    .B
  2005. .C    move.b    (a1)+,d0
  2006.     move.b    (a2)+,d1
  2007.     bsr    compD1D0nocase
  2008.     beq.s    .A
  2009.  
  2010.     move.l    d3,a2
  2011.     move.l    d3,d4
  2012.     move.l    (a2),d3
  2013.     bra    search_next_set
  2014. .B    move.l    d3,d0
  2015.     move.l    d4,d1
  2016.     
  2017.     movem.l    (sp)+,d2-d4/a1-a2
  2018.     rts
  2019.  
  2020.  
  2021. * DO SCRIPT FILE STUFF   ENTRY A0 -> input line
  2022. scr_in    movem.l    a0-a1/a6,-(sp)
  2023.     clr.b    break_flag(a5)
  2024.     move.l    4.w,a6
  2025.     moveq    #0,d0
  2026.     moveq    #0,d1
  2027.     bset    #SIGBREAKB_CTRL_D,d1
  2028.     jsr    _LVOSetSignal(a6)
  2029.     movem.l    (sp)+,a0-a1/a6
  2030.     btst    #SIGBREAKB_CTRL_D,d0    ;checks if CTRL_D pressed
  2031.     beq.s    .B
  2032.     move.l    #304,d0
  2033.     bsr    pr_DOSerr
  2034.     move.b    #1,break_flag(a5)
  2035.     bra.s    terminate_script
  2036. .B    move.l    scsize(a5),d1    ;read a line from the script file
  2037.     add.l    scaddr(a5),d1
  2038.     sub.l    scptr(a5),d1
  2039.     beq.s    terminate_script
  2040.     bpl.s    scr_in2
  2041. terminate_script
  2042.     bsr    kill_script
  2043.     move.l    errorstack(a5),sp
  2044.     bra    chorus
  2045.  
  2046. scr_in2    move.l    a0,a2
  2047.     moveq    #0,d0
  2048.     move.l    scptr(a5),a1
  2049.     cmp.b    #LF,(a1)
  2050.     beq.s    .B
  2051. .A    move.b    (a1)+,(a2)+
  2052.     addq.l    #1,d0
  2053.     cmp.b    #LF,(a1)
  2054.     bne.s    .A
  2055. .B    move.b    (a1)+,(a2)+    LF
  2056.     clr.b    (a2)        0
  2057.     move.l    a1,scptr(a5)
  2058.     btst    #FLdebug,Flags+3(a5)
  2059.     beq.s    .C
  2060.     clr.b    noreview_flag
  2061.     bsr    pr_prompt
  2062.     move.l    a0,a1
  2063.     bsr    pr_string
  2064. .C    rts
  2065.  
  2066. kill_script
  2067.     move.l    a0,-(sp)
  2068.     clr.b    scflag(a5)    clean up if no more lines left
  2069.     clr.b    if_flag(a5)    Make sure if structure ends
  2070.     clr.b    goto_flag(a5)    Make sure goto is terminated
  2071.     move.l    scaddr(a5),a1
  2072.     move.l    scsize(a5),d0
  2073.     bsr    givemem
  2074.     move.l    (sp)+,a0
  2075.     rts
  2076.  
  2077. ** SAME AS compare_strings EXCEPT
  2078. ** ALLOWS FOR A1 ENDING IN LF
  2079. lf_compare_strings
  2080.     movem.l    d0-d1/a0-a1,-(sp)
  2081.     bra.s    .A
  2082. .B    tst.b    d0
  2083.     beq.s    .C    RETURN EQ
  2084. .A    move.b    (a0)+,d0
  2085.     move.b    (a1)+,d1
  2086.     bsr    compD1D0nocase
  2087.     beq.s    .B    return NE
  2088.     tst.b    d0
  2089.     bne.s    .C
  2090.     cmp.b    #LF,d1
  2091. .C    movem.l    (sp)+,d0-d1/a0-a1
  2092.     rts
  2093.  
  2094.     
  2095. ** CASE INDEPENDENT STRING COMPARE. COMPARES (A0) TO (A1)
  2096. ** RETURN EQ IF SAME
  2097. compare_strings
  2098.     movem.l    d0-d1/a0-a1,-(sp)
  2099.     bra.s    .A
  2100. .B    tst.b    d0
  2101.     beq.s    .C    RETURN EQ
  2102. .A    move.b    (a0)+,d0
  2103.     move.b    (a1)+,d1
  2104.     bsr    compD1D0nocase
  2105.     beq.s    .B    return NE
  2106. .C    movem.l    (sp)+,d0-d1/a0-a1
  2107.     rts
  2108.  
  2109.     
  2110. * COPY STRING :copys null ending string from A0 to A1, Return with D0=length+1
  2111. cp_string    movem.l a0-a1,-(sp)
  2112.     moveq #0,d0
  2113. cp_str1    addq.l #1,d0
  2114.     move.b (a0)+,(a1)+
  2115.     bne.s cp_str1
  2116.     movem.l (sp)+,a0-a1
  2117.     rts
  2118.  
  2119. *Get line of text and seperate into up to 6 parameters    
  2120. get_line    addq.l    #1,count_line(a5)
  2121.     bsr    clr_parms
  2122.     lea    shelline(a5),a0
  2123.     tst.b    mult_comm_flag(a5) SKIP PROMPT IF SCRIPT OR MULT COMMANDS
  2124.     bne.s    .A
  2125.     tst.b    scflag(a5)
  2126.     bne.s    .B
  2127.     addq.b    #1,noreview_flag(a5)
  2128.     bsr    pr_prompt
  2129. .B    bsr    type_in    NOTE HISTORY STUFF ASSUMES SHELLINE HOLDS THE LINE
  2130.     clr.b    noreview_flag(a5)
  2131.     cmp.b    #';',(a0)        ;is 1st character a ';'
  2132.     beq.s    .C
  2133.     cmp.b    #'*',(a0)
  2134.     beq.s    .C
  2135.     cmp.b    #'#',(a0)
  2136.     bne.s    .A
  2137. .C    addq.l    #4,sp        ;kill return address
  2138.     bra    chorus        ;do next line if comment
  2139. .A    bsr    handle_mult_comms    MAYBE ALTER A0
  2140.     bsr    handle_command_alias
  2141.     bsr    handle_redirection
  2142.     btst    #FLdebug,Flags+3(a5)
  2143.     beq.s    gl16
  2144.     tst.b    scflag(a5)
  2145.     bne.s    gl16
  2146.     move.l    a0,-(sp)        TEST STUFF
  2147.     lea    pfeil(pc),a1
  2148.     bsr    pr_string
  2149.     move.l    a0,a1
  2150.     bsr    pr_string
  2151.     move.l    (sp)+,a0
  2152. gl16    lea    parm1(a5),a2 do 1st parm seperate to establish CLI residue
  2153.     bsr    get_parm
  2154.     move.l    a0,d7
  2155.     tst.l    d2
  2156.     beq    gl3            if no parms at all
  2157.     tst.b    goto_flag(a5)    CHECK IF IN GOTO SEARCH MODE
  2158.     beq.s    test_ifs
  2159.     move.l    a0,-(sp)
  2160.     lea    labeltx(pc),a0
  2161.     bsr    lf_compare_strings
  2162.     bne    skipline
  2163.     move.l    (sp)+,a0
  2164.  
  2165. * Script-IF handling
  2166. test_ifs    tst.b    if_flag(a5)    0 if if encountered earlier
  2167.     beq.s    no_ifs
  2168.     tst.b    if_condition(a5)    0 if condition TRUE
  2169.     beq    no_ifs
  2170. if_false    move.l    a0,-(sp)        push ptr to next
  2171.     lea    elsetx(pc),a0
  2172.     bsr    lf_compare_strings
  2173.     bne.s    try_endif
  2174.     not.b    if_condition(a5)    flip condition flag
  2175. skipline    movem.l    (sp)+,d0-d1    get rid of last plus return address
  2176.     bra    chorus
  2177. try_endif    lea    endiftx(pc),a0
  2178.     bsr    lf_compare_strings
  2179.     bne.s    skipline
  2180.     clr.b    if_flag(a5)
  2181.     bra.s    skipline
  2182.  
  2183. no_ifs    move.l    a1,(a2)+    save address of parm1
  2184.  
  2185.     lea    CLIbuf(a5),a1
  2186. .C    move.b    (a0)+,d0    skip all preceding spaces
  2187.     cmp.b    #LF,d0
  2188.     beq    .D
  2189.     cmp.b    #" ",d0
  2190.     beq.s    .C
  2191. .B    move.b    d0,(a1)+
  2192.     move.b    (a0)+,d0    copy sudoCLIresidue out
  2193.     cmp.b    #LF,d0        only look for LF end
  2194.     bne.s    .B
  2195. .E    move.b    -(a1),d0    skip all ending spaces
  2196.     cmp.b    #" ",d0
  2197.     beq.s    .E
  2198.     addq.l    #1,a1
  2199. .D    clr.b    (a1)        null end the copy
  2200.     move.l    d7,a0
  2201.     lea    endofparms(a5),a4    establish end of parms block
  2202. gl4    bsr    get_parm        
  2203.     tst.l    d2
  2204.     beq.s    gl3
  2205.     move.l    a1,(a2)+
  2206.     cmp.l    a2,a4        get out if more than 25 parms
  2207.     bne.s    gl4
  2208.     clr.b    (a0)        make sure parm ends in 0
  2209. gl3    rts
  2210.  
  2211. endifz    clr.b    if_flag(a5)
  2212.     moveq    #RETURN_OK,d0
  2213.     rts
  2214. elsez    not.b    if_condition(a5)
  2215.     moveq    #RETURN_OK,d0
  2216.     rts
  2217.  
  2218. *************************
  2219. *        SKIP         *
  2220. *************************
  2221.  
  2222. skipz    move.l    parm2(a5),d1
  2223.     beq    too_less_args
  2224. test_gs    tst.b    scflag(a5)    CAN ONLY GOTO FROM WITHIN SCRIPT
  2225.     bne.s    .A
  2226.     moveq    #RETURN_ERROR,d0
  2227.     rts
  2228. .A    move.l    d1,a0
  2229.     lea    dest_label(a5),a1
  2230. .B    move.b    (a0)+,(a1)+
  2231.     bne.s    .B
  2232.     move.l    scaddr(a5),scptr(a5)  RESET TO START OF SCRIPT
  2233.     move.b    #$ff,goto_flag(a5)
  2234.     clr.b    if_flag(a5)    MAKE SURE IF IS TERMINATED
  2235.     moveq    #RETURN_OK,d0
  2236.     rts
  2237.  
  2238. *************************
  2239. *    LABEL        *     DOES NOTHING IF NOT IN GOTO SEARCH MODE
  2240. *************************
  2241. labelz    tst.b    goto_flag(a5)
  2242.     bne.s    .A
  2243. .B    moveq    #RETURN_OK,D0
  2244.     RTS
  2245. .A    move.l    parm2(a5),d0
  2246.     beq.s    .B
  2247.     move.l    d0,a0
  2248.     lea    dest_label(a5),a1
  2249.     bsr    compare_strings
  2250.     bne    .B
  2251.     clr.b    goto_flag(a5)
  2252.     bra.s    .B
  2253.     
  2254.     
  2255. *ENTRY A0=shelline    ONLY HANDLES ALIASES OF FIRST KEYWORD.
  2256. handle_command_alias
  2257.     movem.l    d0-d2/a1-a4,-(sp)
  2258.     cmp.b    #LF,(a0)
  2259.     beq    hca_nothing_typed
  2260.     move.l    a0,a1
  2261.     lea    tempbuf(a5),a3
  2262.     move.b    #LF,(a3)
  2263.     clr.b    1(a3)    must be null end string
  2264.     lea    temp2buf(a5),a2    COPY PARM AT A0 TO SEARCH STR
  2265. .B    move.b    (a1)+,(a2)+
  2266.     cmp.b    #LF,(a1)
  2267.     beq.s    .D        hca_one_parm
  2268.     cmp.b    #$20,(a1)
  2269.     bne.s    .B
  2270. .D    move.b    (a1)+,(a3)+    COPY FROM SPACE ONWARDS to tempbuf
  2271.     bne.s    .D    WHOLE LINE ENDS IN NULL.
  2272. hca_one_parm
  2273.     clr.b    (a2)    null end search string
  2274.  
  2275. hca_find_it
  2276.     move.l    a0,-(sp)
  2277.     bsr    search_sets
  2278.     move.l    (sp)+,a0
  2279.     tst.l    d0
  2280.     beq    hca_nothing_typed
  2281.     move.l    d0,a2
  2282.  
  2283.     lea    set_defn(a2),a2    A2=set defn
  2284.     lea    tempbuf(a5),a3    A3=line after alias
  2285.     move.l    a0,a1        A1=shelline ptr
  2286.     moveq    #7,d0
  2287. .F    clr.l    -(sp)        push down eight times 0=no entry.
  2288.     dbra    d0,.F
  2289. .E    move.b    (a2)+,d0        handle %1...$1
  2290.     beq    not_much_of_an_alias
  2291.     cmp.b    #$20,d0        skip spaces
  2292.     beq.s    .E
  2293.     cmp.b    #'%',d0
  2294.     bne.s    no_extra_parms
  2295.     move.b    (a2)+,d0
  2296.     and.w    #$0007,d0        only allow %0 --> %7
  2297. .A    move.b    (a3)+,d1        find where the next param starts
  2298.     cmp.b    #LF,d1
  2299.     beq.s    .C        if no param then pt A3 to lf again
  2300.     cmp.b    #$20,d1
  2301.     beq.s    .A
  2302. .D    lsl.w    #2,d0        x 4
  2303.     move.l    a3,0(sp,d0.w)
  2304.     subq.l    #1,0(sp,d0.w)    put address of param on stack
  2305. .B    move.b    (a3)+,d1        get a3 to pt to next space
  2306.     cmp.b    #LF,d1
  2307.     beq    .C
  2308.     cmp.b    #$20,d1
  2309.     bne.s    .B
  2310. .C    lea    -1(a3),a3        a3 ts to space
  2311.     bra.s    .E        do for more params
  2312. get_next_character
  2313.     move.b    (a2)+,d0
  2314. no_extra_parms
  2315.     cmp.b    #'$',d0
  2316.     bne.s    .A
  2317.     move.b    (a2)+,d0        grab number after $
  2318.     beq.s    not_much_of_an_alias
  2319.     and.w    #$0007,d0
  2320.     lsl.w    #2,d0        x 4
  2321.     move.l    0(sp,d0.w),d1
  2322.     beq.s    get_next_character
  2323.     move.l    d1,a4
  2324. .B    move.b    (a4)+,(a1)+    copy param N
  2325.     cmp.b    #LF,(a4)
  2326.     beq.s    .C
  2327.     cmp.b    #$20,(a4)
  2328.     bne.s    .B
  2329. .C    bra.s    get_next_character
  2330. .A    move.b    d0,(a1)+        copy DEFN -> SHELLINE
  2331.     tst.b    d0
  2332.     bne.s    get_next_character
  2333.  
  2334.     lea    -1(a1),a1
  2335. not_much_of_an_alias
  2336.     lea    32(sp),sp        ** NOTE STACK CHANGE
  2337. .D    move.b    (a3)+,(a1)+    copy tempbuf onto end
  2338.     bne.s    .D
  2339.     clr.b    mult_comm_flag(a5)
  2340.     bsr    handle_mult_comms
  2341.     bsr    handle_command_alias
  2342.     clr.b    mult_comm_flag(a5)
  2343.     bsr    handle_mult_comms    put LF at end Allow for aliases with ;'s
  2344.     
  2345. hca_nothing_typed
  2346.     movem.l    (sp)+,d0-d2/a1-a4
  2347.     rts
  2348.  
  2349.  
  2350.     
  2351. clr_parms    movem.l    a0-a1,-(sp)
  2352.     lea    parm1(a5),a0
  2353.     lea    endofparms(a5),a1
  2354. clr_loop1    clr.l    (a0)+
  2355.     cmp.l    a0,a1
  2356.     bne.s    clr_loop1
  2357.     movem.l    (sp)+,a0-a1
  2358.     rts
  2359.  
  2360. * GET PARM line pted to by A0
  2361. * LINE MUST END IN LF THEN 0
  2362. * returns A1 pointing to the address where the parm starts
  2363. * puts a 0 over the space or lf where it ends .A0 pts to next bit on end
  2364. * return d2=0 if got all possible commands from line
  2365. get_parm    moveq    #$20,d2    D2=delimiter
  2366. get_parm1    move.l    a0,a1    ;make sure we can get the address before
  2367.     move.b    (a0)+,d1    ;skip spaces
  2368.     beq.s    last_parm2
  2369.     cmp.b    #$20,d1
  2370.     beq.s    get_parm1
  2371.     cmp.b    #$9,d1    skip tabs
  2372.     beq.s    get_parm1
  2373.     cmp.b    #LF,d1    ;handle idiots who type spaces at end of line
  2374.     beq.s    last_parm
  2375.     cmp.b    #'"',d1    ;handle double quotes
  2376.     bne.s    gp2
  2377.     addq.l    #1,a1
  2378.     moveq    #'"',d2    SET DELIMITER = "
  2379.     bra.s    gp2
  2380. gp4    addq.l    #1,a0    ;make sure pts to after quotes d1 is dummy
  2381. gp2    move.b    (a0)+,d1    ;a0 pts to after the space on exit
  2382.     cmp.b    #LF,d1
  2383.     beq.s    gp3
  2384.     cmp.b    #$5c,d1    allow for \" (nested quotes)
  2385.     beq.s    gp4
  2386.     cmp.b    d2,d1
  2387.     bne.s    gp2
  2388.     clr.b -1(a0)    ;make sure last byte is 0
  2389.     rts
  2390. last_parm    clr.b -1(a0)
  2391. last_parm2    moveq #0,d2    ;signify the end
  2392.         rts
  2393. gp3    lea -1(a0),a0 if ends in LF then dont null end, catch that next time
  2394.     rts
  2395.  
  2396. close_redirection
  2397.     move.l    stdin(a5),d0
  2398.     cmp.l    inhandle(a5),d0
  2399.     beq    cls_outred
  2400.     move.l    thistask(a5),a0
  2401.     move.l    pr_CIS(a0),d1
  2402.     move.l    d0,pr_CIS(a0)    restore old stdin
  2403.     move.l    d0,inhandle(a5)
  2404.     jsr    _LVOClose(a6)
  2405. cls_outred
  2406.     move.l    stdout(a5),d0
  2407.     cmp.l    outhandle(a5),d0
  2408.     beq    cls_nothing
  2409.     move.l    thistask(a5),a0
  2410.     move.l    pr_COS(a0),d1
  2411.     move.l    d0,pr_COS(a0)    restore old stdout
  2412.     move.l    d0,outhandle(a5)    
  2413.     jsr    _LVOClose(a6)
  2414.     tst.l    MPipePtr(a5)
  2415.     beq.s    cls_nothing
  2416.     movem.l    d2-d7/a2-a4,-(sp)
  2417.     bsr    raw_on
  2418.     sub.l    a3,a3
  2419.     bsr    viewbuffer
  2420.     movem.l    (sp)+,d2-d7/a2-a4
  2421.     clr.l    MPipePtr(a5)
  2422. cls_nothing
  2423.     rts
  2424.     
  2425. * entry A0 pts to shelline
  2426. handle_redirection
  2427.     movem.l    d0/a0-a3,-(sp)
  2428.     lea    tempbuf(a5),a2
  2429. redir_2    move.b    (a0)+,d0    CHECK FOR REDIRECTION CHARS < >
  2430.     cmp.b    #LF,d0
  2431.     bne.s    .C
  2432. .F    movem.l    (sp)+,d0/a0-a3
  2433.     rts
  2434. .C    cmp.b    #'"',d0    HANDLE QUOTES
  2435.     bne.s    .A
  2436. .B    move.b    (a0)+,d0
  2437.     cmp.b    #LF,d0
  2438.     beq    .F
  2439.     cmp.b    #'"',d0
  2440.     bne.s    .B
  2441. .A    cmp.b    #$20,d0
  2442.     bne.s    redir_2
  2443.     move.b    (a0),d0    TEST CHAR AFTER SPACE.
  2444.     cmp.b    #'>',d0
  2445.     beq.s    redir_out
  2446.     cmp.b    #'<',d0
  2447.     bne.s    redir_2
  2448. redir_in
  2449.     move.l    #MODE_OLDFILE,d2
  2450.     cmp.b    #">",1(a0)
  2451.     beq.s    redir_both
  2452.     bsr    redir_open
  2453.     bsr    ChngIn
  2454.     move.l    a3,a0
  2455.     bra    redir_2        KEEP SEARCHING
  2456. redir_both
  2457.     bsr    redir_open
  2458.     bsr    ChngIn
  2459.     bra.s    re_out2
  2460. redir_out
  2461.     cmp.b    #">",1(a0)
  2462.     beq.s    redir_append
  2463.     lea    -1(a0),a3        ALIGN WITH SPACE
  2464.     bsr    copy_redirector
  2465.     move.b    (a2),d0
  2466.     bset    #5,d0
  2467.     cmp.b    #"m",d0
  2468.     bne.s    re_out2
  2469.     tst.b    1(a2)
  2470.     bne.s    re_out2
  2471.     clr.b    (a2)    redir to MORE, send to nil:
  2472.     move.l    ReviewPtr(a5),MPipePtr(a5)
  2473. re_out2    move.l    #MODE_NEWFILE,d2
  2474.     bsr    redir_open2
  2475.     bsr    ChngOut
  2476.     move.l    a3,a0
  2477.     bra    redir_2
  2478. redir_append
  2479.     move.l    #MODE_READWRITE,d2
  2480.     bsr    redir_open
  2481.     bsr    ChngOut
  2482.     move.l    d0,d1
  2483.     moveq    #0,d2    set position
  2484.     moveq    #1,d3    set mode
  2485.     jsr    _LVOSeek(a6)
  2486.     move.l    a3,a0
  2487.     bra    redir_2
  2488.  
  2489. ChngIn    move.l    thistask(a5),a0
  2490.     move.l    d0,pr_CIS(a0)    MAKE STDIN DIFFERENT.
  2491.     move.l    d0,inhandle(a5)
  2492.     rts
  2493. ChngOut    move.l    thistask(a5),a0
  2494.     move.l    d0,pr_COS(a0)
  2495.     move.l    d0,outhandle(a5)
  2496.     rts
  2497.  
  2498. redir_open
  2499.     lea    -1(a0),a3        ALIGN WITH SPACE
  2500.     bsr    copy_redirector
  2501. redir_open2
  2502.     tst.b    (a2)
  2503.     bne.s    .B
  2504.     lea    connil(pc),a2
  2505. .B    btst    #FLdebug,Flags+3(a5)
  2506.     beq.s    .A
  2507.     lea    star(pc),a2
  2508. .A    move.l    a2,d1
  2509.     jsr    _LVOOpen(a6)
  2510.     tst.l    d0
  2511.     beq    DOSerr
  2512.     rts
  2513.     
  2514. ** ENTRY A0 pts redirection symbol. A2 pts to area to save redirection name
  2515. ** EXIT A2 area holds null end string and redirection name is deleted from
  2516. **      shelline
  2517. copy_redirector
  2518.     movem.l    a0-a2,-(sp)
  2519.     move.l    a0,a1    SAVE START OF REDIRECTION STRING
  2520.     move.b    (a0)+,d0    BUMP PAST '<' or '>'
  2521. cpred3    move.b    (a0)+,d0
  2522.     cmp.b    #$20,d0
  2523.     beq.s    cpredsp
  2524.     cmp.b    #LF,d0
  2525.     beq.s    cpredlf
  2526.     cmp.b    #'>',d0    HANDLE APPEND REDIRECTION PROPERLY
  2527.     beq.s    cpred3
  2528.     move.b    d0,(a2)+    COPY NEWSTDIN/OUT TO NONSTDIN/OUT
  2529.     bra.s    cpred3
  2530. cpredlf    lea    -1(a0),a0
  2531.     lea    -1(a1),a1
  2532. cpredsp    clr.b    (a2)+    A0 should point to after the space or lf
  2533.     lea    shelline+SHELLINE_SIZE(a5),a2
  2534.     move.l    a1,d0
  2535.     sub.l    a0,d0
  2536.     add.l    d0,next_comm_ptr(a5)    offset next_comm_ptr
  2537. cpred5    move.b    (a0)+,(a1)+    delete redirection string from shelline
  2538.     cmp.l    a0,a2
  2539.     bhi.s    cpred5
  2540.     movem.l    (sp)+,a0-a2
  2541.     rts
  2542.  
  2543. ** V1.14 multiple commands on command line. Delimit by ';'
  2544. * ENTRY A0 pts to shelline, EXIT A0 pts to start of next bit on line.
  2545. handle_mult_comms
  2546.     movem.l    d0/a1,-(sp)
  2547.     tst.b    mult_comm_flag(a5)
  2548.     beq.s    .A
  2549.     move.l    next_comm_ptr(a5),a0
  2550. .A    move.l    a0,a1
  2551. .B    move.b    (a1)+,d0
  2552.     cmp.b    #$5c,d0        is it \ ?
  2553.     beq.s    .E
  2554.     cmp.b    #'"',d0    ignore semi-colons between quotes
  2555.     bne.s    .C
  2556. .D    move.b    (a1)+,d0
  2557.     beq.s    endofline    END OF LINE IS NULL.
  2558.     cmp.b    #LF,d0
  2559.     beq.s    fndret
  2560.     cmp.b    #'"',d0
  2561.     bne.s    .D
  2562.     bra.s    .B
  2563. .E    move.b    (a1)+,d0
  2564.     bra.s    .F
  2565. .C    cmp.b    #';',d0
  2566.     beq    fndsemi
  2567. .F    cmp.b    #LF,d0
  2568.     bne.s    .B
  2569. fndret    tst.b    (a1)    IF NULL FOLLOWS LF THEN AT END OF LINE
  2570.     bne.s    fndsemi
  2571. endofline    clr.b    mult_comm_flag(a5)
  2572.     movem.l    (sp)+,d0/a1
  2573.     rts
  2574. fndsemi    move.b    #LF,-1(a1)    REPLACE ; or LF WITH LF
  2575.     move.l    a1,next_comm_ptr(a5)
  2576.     move.b    #1,mult_comm_flag(a5)
  2577.     movem.l    (sp)+,d0/a1
  2578.     rts
  2579.  
  2580. ******************************
  2581. * Iconify Shell        V2.3 *
  2582. WaitAppIcon
  2583.     movem.l    d2-d7/a2-a4,-(sp)
  2584.     clr.b    tempbuf(a5)
  2585.     cmp.w    #36,kickver(a5)
  2586.     blo    .G
  2587.     bsr    KillAppWin
  2588.     bsr    raw_off
  2589.     bsr    clkof2
  2590.     bsr    CloseWin
  2591.  
  2592.     tst.l    diskobj(a5)
  2593.     bne.s    .I
  2594.     bsr    OpenIconLib
  2595.     beq.s    .A
  2596.     moveq    #3,d0
  2597.     jsr    _LVOGetDefDiskObject(a6)
  2598.     move.l    d0,diskobj(a5)
  2599.     beq    .A
  2600. .I    bsr    OpenWBLib
  2601.     beq    .A
  2602.     moveq    #0,d0    opened workbench.library
  2603.     moveq    #0,d1
  2604.     move.l    app_name(a5),a0
  2605.     move.l    thistask(a5),a1
  2606.     lea    pr_MsgPort(a1),a1
  2607.     move.l    a1,d3
  2608.     sub.l    a2,a2
  2609.     move.l    diskobj(a5),a3
  2610.     sub.l    a4,a4
  2611.     jsr    _LVOAddAppIconA(a6)    add appicon
  2612.     move.l    d0,d2
  2613.     beq.s    .B
  2614.     move.l    4.w,a6
  2615. .C    move.l    d3,a0
  2616.     jsr    _LVOWaitPort(a6)    wait for one message
  2617.     bsr    GetAppIMsgs
  2618.     move.l    wbbase(a5),a6
  2619.     move.l    d2,a0
  2620.     jsr    _LVORemoveAppIcon(a6)    remove appicon
  2621. .B    bsr    GetAppIMsgs
  2622.  
  2623. .A    move.l    dosbase(a5),a6
  2624.     tst.b    openwin_flag(a5)    restore window
  2625.     beq.s    .G
  2626.     move.l    thistask(a5),a3
  2627.     move.l    CLIptr(a5),a2
  2628.     move.l    windowname(a5),d1
  2629.     clr.b    openwin_flag(a5)
  2630.     bsr    OpenWin
  2631.     beq    cloga
  2632.     jsr    _LVOOutput(a6)    SAVE THE CONSOLE HANDLERS
  2633.     move.l    d0,outhandle(a5)
  2634.     move.l    d0,stdout(a5)
  2635.     jsr    _LVOInput(a6)
  2636.     move.l    d0,inhandle(a5)
  2637.     move.l    d0,stdin(a5)
  2638.     bsr    InitAppWin
  2639.     tst.b    memclk_flag(a5)
  2640.     beq.s    .G
  2641.     bsr    clkon
  2642. .G    movem.l    (sp)+,d2-d7/a2-a4
  2643.     lea    tempbuf(a5),a1
  2644.     tst.b    (a1)
  2645.     beq.s    .D
  2646.     bsr    print_def
  2647. .D    rts
  2648.  
  2649. GetAppIMsgs
  2650.     move.l    4.w,a6
  2651. .B    move.l    d3,a0
  2652.     jsr    _LVOGetMsg(a6)        get all messages
  2653.     tst.l    d0
  2654.     beq.s    .A
  2655.     move.l    d0,a2
  2656.     cmp.w    #8,am_Type(a2)
  2657.     bne.s    .B
  2658.     bsr    ProcessApp
  2659.     move.l    a2,a1
  2660.     jsr    _LVOReplyMsg(a6)    reply them
  2661.     bra.s    .B
  2662. .A    rts
  2663.  
  2664. ProcessApp    ;Message in a2
  2665.     move.l    a2,-(sp)
  2666.     move.l    am_NumArgs(a2),d0
  2667.     move.l    am_ArgList(a2),a0
  2668.     lea    tempbuf(a5),a2
  2669.     bra.s    .D
  2670. .E    move.l    (a0)+,d1    process all args
  2671.     beq.s    .C        get name from lock to dir
  2672.     movem.l    d0-d3/a0/a3/a6,-(sp)
  2673.     move.l    dosbase(a5),a6
  2674.     jsr    _LVODupLock(a6)
  2675.     move.l    a2,a0
  2676.     bsr    eval_full_path
  2677.     jsr    _LVOUnLock(a6)
  2678. .A    tst.b    (a2)+
  2679.     bne.s    .A
  2680.     subq.l    #1,a2
  2681.     cmp.b    #":",-1(a2)
  2682.     beq.s    .B
  2683.     move.b    #"/",(a2)+    /-end path
  2684. .B    movem.l    (sp)+,d0-d3/a0/a3/a6
  2685. .C    move.l    (a0)+,d1    get filename
  2686.     beq.s    .D
  2687.     move.l    d1,a1
  2688.     bsr    addstring
  2689.     move.b    #" ",(a2)+    space-end
  2690. .D    dbra    d0,.E
  2691.     clr.b    (a2)
  2692.     move.l    (sp)+,a2
  2693.     rts
  2694.  
  2695. ** evaluate entire name associated with lock in D0, store string in A0
  2696. ** Return D1 = last lock to unlock
  2697. ** Reg usage: d0,d1,d2,d3,a0,a1,a3 (must not use A2)
  2698.  
  2699. OpenIconLib
  2700.     move.l    iconbase(a5),d0
  2701.     bne.s    .A
  2702.     move.l    4.w,a6
  2703.     lea    iconname(pc),a1
  2704.     jsr    _LVOOldOpenLibrary(a6)    icon-library
  2705.     move.l    d0,iconbase(a5)
  2706. .A    move.l    d0,a6
  2707.     rts
  2708.  
  2709. OpenWBLib
  2710.     move.l    wbbase(a5),d0
  2711.     bne.s    .A
  2712.     move.l    4.w,a6
  2713.     lea    wbname(pc),a1
  2714.     jsr    _LVOOldOpenLibrary(a6)
  2715.     move.l    d0,wbbase(a5)
  2716. .A    move.l    d0,a6
  2717.     rts
  2718.  
  2719. **********************************************
  2720. * Create CLI-Interface-Structure    V2.0 *
  2721. CreateCLI
  2722.     move.l    thistask(a5),a3
  2723.     move.l    pr_WindowPtr(a3),d0
  2724.     move.l    d0,oldwindowptr(a5)    preserve old winptr
  2725.     move.l    d0,windowptr(a5)    default new winptr
  2726.     tst.b    CLIflag(a5)
  2727.     beq    CCli3
  2728.     clr.l    EntryA0(a5)        started from WB
  2729.     move.l    #64+$28+$50,d0
  2730.     move.l    #MEMF_CLEAR+1,d1    memory for CLI
  2731.     bsr    iwantmem
  2732.     moveq    #1,d1
  2733.     tst.l    d0
  2734.     beq    CCli2
  2735.     move.l    d0,a2
  2736.     lsr.l    #2,d0
  2737.     move.l    d0,pr_CLI(a3)
  2738.     move.l    dl_Root(a6),a0
  2739.     move.l    (a0),a0
  2740.     add.l    a0,a0
  2741.     add.l    a0,a0
  2742.     moveq    #0,d2
  2743.     move.l    (a0),d0
  2744.     subq.l    #1,d0
  2745. .C    addq.l    #1,d2
  2746.     addq.l    #4,a0
  2747.     tst.l    (a0)        look for free CLI-Number
  2748.     dbeq    d0,.C
  2749.     moveq    #2,d1
  2750.     tst.l    (a0)
  2751.     bne    CCli2
  2752.     lea    pr_MsgPort(a3),a1
  2753.     move.l    a1,(a0)
  2754.     move.l    d2,pr_TaskNum(a3)
  2755.     moveq    #10,d0
  2756.     move.l    d0,cli_FailLevel(a2)
  2757.     moveq    #-1,d0
  2758.     move.l    d0,cli_Interactive(a2)
  2759.     move.l    #1000,cli_DefaultStack(a2)    1000 LONGs
  2760.     move.l    pr_FileSystemTask(a3),filesys_old(a5)
  2761.     lea    64(a2),a0
  2762.     move.l    a0,d0
  2763.     lsr.l    #2,d0
  2764.     move.l    d0,cli_CommandFile(a2)
  2765.     lea    64+$28(a2),a0
  2766.     move.l    a0,d0
  2767.     lsr.l    #2,d0
  2768.     move.l    d0,cli_CommandName(a2)
  2769.     IFD    DEBUG
  2770.     tst.l    wb_msg(a5)
  2771.     beq    CreateCLI2    no WB-Msg -> CreateCLI2
  2772.     ENDC
  2773.     move.l    wb_msg(a5),a0
  2774.     tst.l    sm_Process(a0)
  2775.     beq    CreateCLI3    newcli/run -> CreateCLI3
  2776.     move.l    sm_ArgList(a0),a1
  2777.     moveq    #2,d0
  2778.     cmp.l    sm_NumArgs(a0),d0
  2779.     bhi.s    .H        Project ?
  2780.     addq.l    #8,a1
  2781. .H    move.l    (a1),a0        Lock on Current Dir
  2782.     moveq    #3,d1
  2783.     move.l    a0,d0
  2784.     beq    CCli2
  2785.     move.l    a0,d1
  2786.     move.l    dosbase(a5),a6
  2787.     jsr    _LVODupLock(a6)        WB wants to free its own lock
  2788.     bsr    SetCurrentDir
  2789.     move.l    4.w,a6
  2790.     lea    wbenchtx(pc),a1
  2791.     jsr    _LVOFindTask(a6)
  2792.     tst.l    d0
  2793.     beq.s    .E
  2794.     move.l    d0,a0
  2795.     tst.l    pr_CLI(a0)
  2796.     beq.s    .E
  2797.     move.l    dosbase(a5),a6
  2798.     bsr    CopyPaths    copy paths from workbench
  2799. .E    bsr    OpenIconLib
  2800.     moveq    #4,d1
  2801.     tst.l    d0
  2802.     beq    CCli2
  2803.     move.l    d0,a4
  2804.     move.l    wb_msg(a5),a0
  2805.     move.l    sm_ArgList(a0),a1
  2806.     moveq    #2,d0
  2807.     cmp.l    sm_NumArgs(a0),d0
  2808.     bhi.s    .I            Project ?
  2809.     move.l    12(a1),d0
  2810.     beq.s    .I
  2811.     move.l    d0,EntryA0(a5)        Name of Project as Script
  2812.     addq.l    #8,a1
  2813. .I    move.l    4(a1),a0        Name of Process
  2814.     jsr    _LVOGetDiskObject(a6)
  2815.     moveq    #5,d1
  2816.     move.l    d0,diskobj(a5)
  2817.     beq    CCli2
  2818.     move.l    d0,a0
  2819.     moveq    #0,d0
  2820.     bset    #31,d0        unset icon position
  2821.     move.l    d0,$3a(a0)    CurrentX
  2822.     move.l    d0,$3e(a0)    CurrentY
  2823.     move.b    #8,$30(a0)    Type=AppIcon
  2824.     move.l    do_ToolTypes(a0),d3    d3=ToolTypes
  2825.     move.l    d3,a0
  2826.     lea    xpostool(pc),a1
  2827.     jsr    _LVOFindToolType(a6)    Look for XPOS-ToolType
  2828.     tst.l    d0
  2829.     beq.s    .G
  2830.     move.l    d0,a1
  2831.     bsr    convert_ASCII_to_num
  2832.     beq.s    .G
  2833.     move.l    diskobj(a5),a0
  2834.     move.l    d0,$3a(a0)
  2835. .G    move.l    d3,a0
  2836.     lea    ypostool(pc),a1
  2837.     jsr    _LVOFindToolType(a6)    Look for YPOS-ToolType
  2838.     tst.l    d0
  2839.     beq.s    .J
  2840.     move.l    d0,a1
  2841.     bsr    convert_ASCII_to_num
  2842.     beq.s    .J
  2843.     move.l    diskobj(a5),a0
  2844.     move.l    d0,$3e(a0)
  2845. .J    move.l    d3,a0
  2846.     lea    nametool(pc),a1
  2847.     jsr    _LVOFindToolType(a6)    Look for ICONNAME-ToolType
  2848.     tst.l    d0
  2849.     beq.s    .K
  2850.     move.l    d0,app_name(a5)
  2851. .K    move.l    d3,a0
  2852.     lea    iconifytool(pc),a1
  2853.     jsr    _LVOFindToolType(a6)    Look for ICONIFY-ToolType
  2854.     tst.l    d0
  2855.     beq.s    .B
  2856.     bset    #FLappicon,Flags+3(a5)
  2857.     movem.l    d2-d5/a6,-(sp)
  2858.     moveq    #0,d4
  2859.     moveq    #0,d5
  2860.     bsr    WaitAppIcon
  2861.     movem.l    (sp)+,d2-d5/a6
  2862. .B    move.l    d3,a0
  2863.     lea    screentool(pc),a1
  2864.     jsr    _LVOFindToolType(a6)    Look for SCREEN-ToolType
  2865.     move.l    d0,pubname(a5)
  2866.     move.l    d3,a0
  2867.     lea    wintool(pc),a1
  2868.     jsr    _LVOFindToolType(a6)    Look for WINDOW-ToolType
  2869.     lea    conname(pc),a0
  2870.     tst.l    d0
  2871.     beq.s    .D
  2872.     move.l    d0,a0
  2873. .D    move.l    a0,d1
  2874.     move.l    dosbase(a5),a6
  2875.     bsr    OpenWin            Open Window
  2876.     beq    CCli2a
  2877.     move.l    d3,a0
  2878.     lea    scripttool(pc),a1
  2879.     move.l    a4,a6
  2880.     jsr    _LVOFindToolType(a6)    Look for SCRIPT-ToolType
  2881.     tst.l    EntryA0(a5)    project ?
  2882.     bne.s    .F
  2883.     move.l    d0,EntryA0(a5)
  2884. .F    move.l    d3,a0
  2885.     lea    norawtool(pc),a1
  2886.     jsr    _LVOFindToolType(a6)    Look for NORAW-ToolType
  2887.     tst.l    d0
  2888.     beq.s    .A
  2889.     clr.l    ConsoleSwitch(a5)
  2890. .A    move.l    d3,a0
  2891.     lea    commandtool(pc),a1
  2892.     jsr    _LVOFindToolType(a6)    Look for COMMAND-ToolType
  2893.     move.l    d0,d2
  2894.     bsr    Com2Script
  2895.     bne.s    CCli2a
  2896. CCli1    move.l    dosbase(a5),a6
  2897.     moveq    #0,d0
  2898.     rts
  2899. CCli2    bsr    GuruIt
  2900. CCli2a    move.l    dosbase(a5),a6
  2901.     moveq    #-1,d0
  2902.     rts
  2903.  
  2904. CCli3    move.l    pr_COS(a3),outhandle(a5)    started from CLI
  2905.     move.l    pr_ConsoleTask(a3),ConsoleSwitch(a5)
  2906.     move.l    pr_CurrentDir(a3),d1
  2907.     bne.s    .D
  2908.     moveq    #-2,d2
  2909.     jsr    _LVOLock(a6)
  2910.     tst.l    d0
  2911.     beq    .D
  2912.     bsr    SetCurrentDir
  2913. .D    move.l    EntryA0(a5),d0    process CLI-Command-Line
  2914.     beq.s    CCli1
  2915.     clr.l    EntryA0(a5)
  2916.     move.l    d0,a0
  2917.     lea    parm2(a5),a2
  2918.     lea    endofparms(a5),a4    establish end of parms block
  2919. .A    bsr    get_parm        
  2920.     tst.l    d2
  2921.     beq.s    .B
  2922.     move.l    a1,(a2)+
  2923.     cmp.l    a2,a4        get out if more than 25 parms
  2924.     bne.s    .A
  2925.     clr.b    (a0)        make sure last parm ends in 0
  2926. .B    lea    parm2(a5),a1
  2927.     bsr.s    StartOpts
  2928.     bne.s    CCli2a
  2929.     tst.l    d3
  2930.     beq.s    .C
  2931.     clr.l    ConsoleSwitch(a5)
  2932. .C    tst.l    d1
  2933.     beq.s    CCli1
  2934.     move.l    thistask(a5),a3
  2935.     move.l    pr_CLI(a3),a2
  2936.     add.l    a2,a2
  2937.     add.l    a2,a2
  2938.     bsr    OpenWin
  2939.     tst.l    d0
  2940.     beq.s    CCli2a
  2941.     tst.l    d3
  2942.     beq    CCli1
  2943.     clr.l    ConsoleSwitch(a5)
  2944.     bra    CCli1
  2945.  
  2946. StartOpts        ;examine startup-options, parms in a1
  2947.     moveq    #0,d1
  2948.     moveq    #0,d2
  2949.     moveq    #0,d3
  2950. .A    move.l    (a1)+,d0    ;returns window in d1, script in EntryA0
  2951.     beq.s    Com2Script    ;and start-command in d2, d3>0 if noraw
  2952.     move.l    d0,a0        ;screen in pubname
  2953.     cmp.b    #"-",(a0)+
  2954.     bne.s    .H
  2955.     move.b    (a0)+,d0
  2956.     or.b    #$20,d0
  2957.     cmp.b    #"s",d0        -s for Script
  2958.     bne.s    .B
  2959.     move.l    a0,EntryA0(a5)
  2960.     bra.s    .A
  2961. .B    cmp.b    #"w",d0        -w for Window
  2962.     bne.s    .C
  2963.     move.l    a0,d1
  2964.     bra.s    .A
  2965. .C    cmp.b    #"c",d0        -c for Command
  2966.     bne.s    .D
  2967.     move.l    a0,d2
  2968.     bra.s    .A
  2969. .D    cmp.b    #"d",d0        -d for detach
  2970.     bne.s    .E
  2971.     clr.l    -4(a1)
  2972.     bsr    initialise_default
  2973.     bsr    newcliz
  2974.     bra.s    .I
  2975. .E    cmp.b    #"r",d0        -r for not Resident
  2976.     beq.s    .A
  2977.     cmp.b    #"n",d0        -n for Noraw
  2978.     bne.s    .F
  2979.     moveq    #1,d3
  2980.     bra.s    .A
  2981. .F    cmp.b    #"e",d0        -e for scrEen
  2982.     bne.s    .H
  2983.     move.l    a0,pubname(a5)
  2984.     bra.s    .A
  2985. .H    lea    useit(pc),a1
  2986.     bsr    pr_stringlf
  2987. .I    moveq    #-1,d0
  2988.     rts
  2989.  
  2990. Com2Script        ;Makes a command to script, d2=command
  2991.     move.l    d1,-(sp)    ;returns d0=0 for OK
  2992.     moveq    #1,d0
  2993.     tst.l    d2
  2994.     beq.s    .B
  2995.     lea    null(pc),a0
  2996.     move.l    a0,EntryA0(A5)
  2997.     move.l    d2,a0
  2998.     moveq    #0,d0
  2999. .A    addq.l    #1,d0
  3000.     tst.b    (a0)+
  3001.     bne.s    .A
  3002.     move.l    d0,scsize(a5)
  3003.     moveq    #1,d1
  3004.     bsr    iwantmem
  3005.     beq.s    .B
  3006.     move.l    d0,scaddr(a5)
  3007.     move.l    d0,scptr(a5)
  3008.     move.b    #1,scflag(a5)    make shell think text lines are in memory
  3009.     move.l    d0,a1
  3010.     move.l    d2,a0
  3011. .C    move.b    (a0)+,(a1)+
  3012.     bne.s    .C
  3013.     move.b    #LF,-1(a1)
  3014.     moveq    #1,d0
  3015. .B    move.l    (sp)+,d1
  3016.     subq.l    #1,d0
  3017.     rts
  3018.  
  3019. SetCurrentDir    ;lock in d0
  3020.     move.l    d0,a0
  3021.     add.l    a0,a0
  3022.     add.l    a0,a0
  3023.     move.l    fl_Task(a0),pr_FileSystemTask(a3)
  3024.     move.l    d0,d1
  3025.     jsr    _LVOCurrentDir(a6)
  3026.     move.l    d0,cdir_old(a5)
  3027.     rts
  3028.  
  3029. * Open Window for both Input and Output, Name in d1 , a2,a3 *
  3030. OpenWin    move.l    dosbase(a5),a6
  3031.     moveq    #0,d0
  3032.     cmp.b    #1,openwin_flag(a5)
  3033.     beq    .C
  3034.     move.b    #1,openwin_flag(a5)
  3035.     move.l    pr_CIS(a3),OldCIS(a5)
  3036.     move.l    pr_COS(a3),OldCOS(a5)
  3037.     clr.l    pr_CIS(a3)        avoid freeing it
  3038.     clr.l    pr_COS(a3)
  3039.     move.l    pr_ConsoleTask(a3),OldCTask(a5)
  3040.     clr.l    ConsoleSwitch(a5)
  3041.     move.l    d1,a0
  3042.     move.l    a0,windowname(a5)
  3043.     tst.b    (a0)
  3044.     beq    .A            NIL:
  3045.     cmp.w    #36,kickver(a5)
  3046.     blo    .D
  3047.     move.l    pubname(a5),d0
  3048.     beq    .D
  3049.  
  3050.     movem.l    d1-d2/a2,-(sp)    open Public Screen
  3051.     lea    PubTags(pc),a0
  3052.     lea    temp2buf(a5),a1        copy tags-field
  3053.     move.l    a1,a2
  3054. .E    move.l    (a0)+,(a1)+
  3055.     clr.l    (a1)+
  3056.     tst.l    -8(a1)
  3057.     bne.s    .E
  3058.     move.l    d0,a1
  3059.     moveq    #2,d0
  3060.     addq.l    #1,a1
  3061.     tst.b    -1(a1)
  3062.     beq.s    .H
  3063.     subq.l    #1,a1
  3064.     bsr    convert_ASCII_to_num
  3065. .H    move.l    d0,1*4(a2)    Depth
  3066.     move.l    #$8000,d0
  3067.     tst.b    -1(a1)
  3068.     beq.s    .I
  3069.     bsr    convert_ASCII_to_num
  3070. .I    move.l    d0,9*4(a2)    DisplayID
  3071.     moveq    #1,d0
  3072.     tst.b    -1(a1)
  3073.     beq.s    .J
  3074.     bsr    convert_ASCII_to_num
  3075. .J    move.l    d0,11*4(a2)    Overscan
  3076.     lea    ZShellName(pc),a0    fill up tags-field
  3077.     tst.b    -1(a1)
  3078.     beq.s    .G
  3079.     move.l    a1,a0
  3080. .G    move.l    a0,3*4(a2)    Screentitle
  3081.     move.l    a0,7*4(a2)
  3082.     moveq    #2,d0
  3083.     move.l    d0,5*4(a2)    Pubscreen
  3084.     moveq    #12,d0
  3085.     move.l    d0,13*4(a2)    PubSig=ctrl-C
  3086.     lea    PenAray(pc),a0
  3087.     move.l    a0,15*4(a2)    Drawinfo
  3088.     move.l    a2,a1
  3089.     sub.l    a0,a0
  3090.     move.l    intuibase(a5),a6
  3091.     jsr    _LVOOpenScreenTagList(a6)    open Screen
  3092.     move.l    d0,pubscreen(a5)
  3093.     beq.s    .F
  3094.     move.l    d0,a0
  3095.     moveq    #0,d0
  3096.     jsr    _LVOPubScreenStatus(a6)    make Pubscreen public
  3097. .F    move.l    dosbase(a5),a6
  3098.     movem.l    (sp)+,d1-d2/a2
  3099.  
  3100. .D    move.l    #MODE_NEWFILE,d2
  3101.     jsr    _LVOOpen(a6)        open output-Window
  3102.     moveq    #11,d1
  3103.     move.l    d0,pr_COS(a3)
  3104.     beq    .B
  3105.     move.l    d0,d1
  3106.     move.l    d0,cli_StandardOutput(a2)
  3107.     move.l    d0,cli_CurrentOutput(a2)
  3108.     lsl.l    #2,d0
  3109.     move.l    d0,a0
  3110.     move.l    fh_Type(a0),d0
  3111.     move.l    d0,pr_ConsoleTask(a3)
  3112.     move.l    d0,ConsoleSwitch(a5)
  3113.     jsr    _LVOIsInteractive(a6)
  3114.     moveq    #12,d1
  3115.     tst.l    d0
  3116.     beq.s    .B
  3117.     lea    star(pc),a0
  3118.     move.l    a0,d1
  3119.     move.l    #MODE_OLDFILE,d2
  3120.     jsr    _LVOOpen(a6)        open input-window
  3121.     moveq    #13,d1
  3122.     move.l    d0,pr_CIS(a3)
  3123.     beq    .B
  3124.     move.l    d0,cli_StandardInput(a2)
  3125.     move.l    d0,cli_CurrentInput(a2)
  3126.     bsr    GetWindowPtr
  3127.     beq.s    .A
  3128.     move.l    d0,windowptr(a5)
  3129.     move.l    d0,pr_WindowPtr(a3)
  3130. .A    moveq    #-1,d0
  3131.     rts            d0<>0 if OK
  3132. .C    moveq    #10,d1
  3133. .B    bra    GuruIt        d0=0 on error
  3134.  
  3135. PubTags    dc.l    $80000000+37    Depth=2/1
  3136.     dc.l    $80000000+40    Title=*ZShell/3
  3137.     dc.l    $80000000+45    Type=Publicscreen/5
  3138.     dc.l    $80000000+47    PubName=*ZShell/7
  3139.     dc.l    $80000000+50    DisplayID=Hires/9
  3140.     dc.l    $80000000+52    Overscan=1/11
  3141.     dc.l    $80000000+48    PubSig=12/13
  3142.     dc.l    $80000000+58    Pens=*PenArray/15
  3143.     dc.l    0
  3144. PenAray    dc.w    0,-1
  3145.  
  3146. CloseWin
  3147.     move.l    thistask(a5),a3
  3148.     tst.b    openwin_flag(a5)
  3149.     beq.s    .A
  3150.     move.l    pr_CIS(a3),d1
  3151.     beq.s    .C
  3152.     jsr    _LVOClose(a6)    close input-window
  3153. .C    move.l    pr_COS(a3),d1
  3154.     beq.s    .D
  3155.     jsr    _LVOClose(a6)    close output-window
  3156. .D    move.l    OldCIS(a5),d0
  3157.     move.l    d0,pr_CIS(a3)
  3158.     move.l    OldCOS(a5),d1
  3159.     move.l    d1,pr_COS(a3)
  3160.     move.l    OldCTask(a5),pr_ConsoleTask(a3)
  3161.     tst.l    pr_CLI(a3)
  3162.     beq.s    .G
  3163.     move.l    pr_CLI(a3),a2
  3164.     add.l    a2,a2
  3165.     add.l    a2,a2
  3166.     move.l    d0,cli_StandardInput(a2)
  3167.     move.l    d0,cli_CurrentInput(a2)
  3168.     move.l    d1,cli_StandardOutput(a2)
  3169.     move.l    d1,cli_CurrentOutput(a2)
  3170. .G    move.l    pubscreen(a5),d0
  3171.     beq.s    .A
  3172.     move.l    d0,a0
  3173.     move.l    intuibase(a5),a6
  3174.     jsr    _LVOCloseScreen(a6)    close Public Screen
  3175.     tst.l    d0
  3176.     bne.s    .A
  3177.     move.l    4.w,a6
  3178.     moveq    #0,d0
  3179.     bset    #SIGBREAKB_CTRL_C,d0
  3180.     jsr    _LVOWait(a6)
  3181.     bra.s    .G
  3182. .A    move.l    dosbase(a5),a6
  3183.     rts
  3184.  
  3185. * Create CLI-Interface-Structure without WB-Message    V2.0 *
  3186.     IFD    DEBUG
  3187. CreateCLI2
  3188.     lea    conname(pc),a0
  3189.     move.l    a0,d1
  3190.     bsr    OpenWin
  3191.     beq.s    .B
  3192.     lea    ramdisk(pc),a0
  3193.     move.l    a0,d1
  3194.     moveq    #-2,d2
  3195.     jsr    _LVOLock(a6)
  3196.     tst.l    d0
  3197.     beq    .B
  3198.     bsr    SetCurrentDir
  3199.     moveq    #0,d0
  3200.     rts
  3201. .B    moveq    #-1,d0
  3202.     rts
  3203.  
  3204. ramdisk    dc.b    "RAM:",0
  3205.     even
  3206.     ENDC
  3207.  
  3208. * Create CLI-Interface-Structure with special message    V2.0 *
  3209. *    a3:Process    a2:CLI_Struct    *
  3210. *sm_NumArgs:    General Memory Block
  3211. *sm_ToolWindow:    Current Dir
  3212. CreateCLI3
  3213.     move.b    #1,WBflag(a5)    not started from WB
  3214.     move.l    sm_NumArgs(a0),a4    wb_msg in a0
  3215.     move.l    Flags(a4),Flags(a5)
  3216.     move.l    app_name(a4),app_name(a5)
  3217.     move.l    pubname(a4),pubname(a5)
  3218.     move.l    thistask(a4),a0
  3219.     move.l    pr_CurrentDir(a0),d1
  3220.     move.l    pr_CLI(a0),a0
  3221.     add.l    a0,a0
  3222.     add.l    a0,a0
  3223.     move.l    cli_DefaultStack(a0),cli_DefaultStack(a2)
  3224.     move.l    cli_FailLevel(a0),cli_FailLevel(a2)
  3225.     jsr    _LVODupLock(a6)        COPY CD
  3226.     moveq    #15,d1
  3227.     tst.l    d0
  3228.     beq    cce3
  3229.     bsr    SetCurrentDir
  3230.     move.l    outhandle(a4),outhandle(a5)    PROCESS PARMS
  3231.     lea    parm2(a4),a1
  3232.     bsr    StartOpts
  3233.     clr.l    outhandle(a5)
  3234.     tst.l    d0
  3235.     bne    cce2
  3236.     move.l    thistask(a4),a0        OPEN WINDOW
  3237.     move.l    pr_ConsoleTask(a0),pr_ConsoleTask(a3)
  3238.     lea    conname(pc),a0
  3239.     tst.l    d1
  3240.     bne.s    .H
  3241.     move.l    a0,d1
  3242.     move.l    windowname(a4),d0
  3243.     beq.s    .H
  3244.     move.l    d0,d1
  3245. .H    bsr    OpenWin
  3246.     beq    cce2
  3247.     tst.l    d3
  3248.     beq.s    .B
  3249.     clr.l    ConsoleSwitch(a5)
  3250. .B    move.l    thistask(a4),a0            COPY SEARCH PATHS
  3251.     bsr    CopyPaths
  3252.     lea    prompt_args(a4),a0    COPY PROMPT
  3253.     lea    prompt_args(a5),a1
  3254. .G    move.b    (a0)+,(a1)+
  3255.     bne.s    .G
  3256.     lea    now(a4),a0        COPY HISTORY
  3257.     lea    now(a5),a1
  3258.     move.w    #HISTORY_SIZE+12-1,d0
  3259. .D    move.b    (a0)+,(a1)+
  3260.     dbra    d0,.D
  3261.     moveq    #ctrl_inite-ctrl_init-1,d0    COPY CTRL-CODES
  3262.     lea    ctrl_codes(a4),a0
  3263.     lea    ctrl_codes(a5),a1
  3264. .E    move.b    (a0)+,(a1)+
  3265.     dbra    d0,.E
  3266.     lea    ignoreit(a4),a0
  3267.     lea    ignoreit(a5),a1
  3268. .F    move.b    (a0)+,(a1)+
  3269.     bne    .F
  3270. ccs3    movem.l    a2-a4,-(sp)    COPY ALL ALIASES
  3271.     moveq    #0,d3        Link Pointer
  3272.     move.l    first_set_defn(a4),d0    old aliases
  3273.     beq    .A
  3274. .B    move.l    d0,a3
  3275.     move.l    set_size(a3),d0
  3276.     move.l    d0,d2
  3277.     moveq    #1,d1
  3278.     bsr    iwantmem    get mem for set
  3279.     beq.s    .A
  3280.     move.l    d0,a2
  3281.     move.l    a3,a0        copy whole set
  3282.     move.l    a2,a1
  3283.     move.l    d2,d1
  3284.     subq.l    #1,d2
  3285. .C    move.b    (a0)+,(a1)+
  3286.     dbra    d2,.C
  3287.     move.l    d1,set_size(a2)    init set
  3288.     move.l    d3,(a2)
  3289.     move.l    a2,d3
  3290.     move.l    (a3),d0        check next set address
  3291.     bne    .B
  3292. .A    move.l    d3,first_set_defn(a5)
  3293.     move.l    ReviewSize(a4),d0    CREATE REVIEW-BUFFER
  3294.     beq.s    .D
  3295.     bsr    MakeReview
  3296. .D    movem.l    (sp)+,a2-a4
  3297.     move.l    EntryA0(a5),d0        SCRIPT GIVEN ?
  3298.     beq.s    .H
  3299.     move.l    d0,a0
  3300.     lea    prompt_string(a5),a1    there is enough place
  3301.     move.l    a1,EntryA0(a5)
  3302. .F    move.b    (a0)+,(a1)+    Copy Script-Parm
  3303.     bne.s    .F
  3304. .H    move.l    4.w,a6
  3305.     move.l    wb_msg(a5),a1
  3306.     jsr    _LVOReplyMsg(a6)
  3307.     clr.l    wb_msg(a5)
  3308.     move.l    dosbase(a5),a6
  3309.     moveq    #0,d0
  3310.     rts
  3311. cce3    bsr    GuruIt
  3312. cce2    moveq    #-1,d0
  3313.     rts
  3314.  
  3315.  
  3316. * Remove CLI-Interface-Structure    V2.0 *
  3317. RemoveCLI
  3318.     move.l    thistask(a5),a3
  3319.     move.l    oldwindowptr(a5),pr_WindowPtr(a3)
  3320.     move.l    old_homedir(a5),d0
  3321.     beq.s    .B
  3322.     move.l    d0,pr_HomeDir(a3)
  3323. .B    move.l    cdback(a5),d1
  3324.     beq.s    .H
  3325.     jsr    _LVOUnLock(a6)
  3326.  
  3327. .H    bsr    clkoff
  3328.     bsr    CloseWin
  3329.     move.l    diskobj(a5),d0
  3330.     beq.s    .F
  3331.     move.l    d0,a0
  3332.     move.l    iconbase(a5),a6
  3333.     jsr    _LVOFreeDiskObject(a6)
  3334. .F    move.l    4.w,a6
  3335.     move.l    iconbase(a5),d0
  3336.     beq.s    .A
  3337.     move.l    d0,a1
  3338.     jsr    _LVOCloseLibrary(a6)
  3339. .A    move.l    wbbase(a5),d0
  3340.     beq.s    .I
  3341.     move.l    d0,a1
  3342.     jsr    _LVOCloseLibrary(a6)
  3343. .I    move.l    dosbase(a5),a6
  3344.     move.l    pr_CLI(a3),d0
  3345.     beq    remend
  3346.     lsl.l    #2,d0
  3347.     move.l    d0,a2
  3348.     moveq    #10,d0
  3349.     move.l    d0,cli_FailLevel(a2)
  3350.     move.l    old_setname(a5),d0
  3351.     beq.s    remcli
  3352.     move.l    d0,cli_SetName(a2)
  3353.     lsl.l    #2,d0
  3354.     move.l    d0,a1
  3355.     lea    CD_string(a5),a0
  3356. .E    move.b    (a0)+,(a1)+    copy current dir name
  3357.     bne.s    .E
  3358.     move.l    old_prompt(a5),cli_Prompt(a2)
  3359.  
  3360. remcli    tst.b    CLIflag(a5)
  3361.     beq.s    remend
  3362.     clr.l    pr_CLI(a3)    clear CLI-Pointer
  3363.     move.l    pr_TaskNum(a3),d0
  3364.     beq.s    .E
  3365.     lsl.l    #2,d0
  3366.     move.l    dl_Root(a6),a0
  3367.     move.l    (a0),a0
  3368.     add.l    a0,a0
  3369.     add.l    a0,a0
  3370.     add.l    d0,a0
  3371.     clr.l    (a0)        free task-number
  3372.     clr.l    pr_TaskNum(a3)
  3373. .E    lea    cli_CommandDir(a2),a4
  3374.     bsr    DeletePaths    free search paths
  3375.     move.l    cdir_old(a5),d1
  3376.     jsr    _LVOCurrentDir(a6)
  3377.     move.l    d0,d1
  3378.     beq.s    .B
  3379.     jsr    _LVOUnLock(a6)    free current dir
  3380. .B    move.l    filesys_old(a5),pr_FileSystemTask(a3)
  3381.     clr.l    pr_Result2(a3)
  3382.     move.l    #64+$28+$50,d0
  3383.     move.l    a2,a1
  3384.     bsr    givemem        free memory of CLI
  3385. remend    move.l    dosbase(a5),a6
  3386.     rts
  3387.  
  3388. GuruIt    ;get errornumber in d1 and display a recoverable alert
  3389.     movem.l    d0-d1/a0-a2/a6,-(sp)
  3390.     lea    tempbuf(a5),a0
  3391.     move.l    a0,a1
  3392.     clr.b    (a1)+
  3393.     move.b    #250,(a1)+
  3394.     move.b    #15,(a1)+
  3395.     lea    ZShellName(pc),a2
  3396. .A    move.b    (a2)+,(a1)+
  3397.     bne.s    .A
  3398.     move.b    #" ",-1(a1)
  3399.     move.l    d1,d0
  3400.     bsr    qpr10
  3401.     clr.b    (a1)+
  3402.     clr.b    (a1)+
  3403.     move.l    intuibase(a5),a6
  3404.     moveq    #0,d0
  3405.     moveq    #35,d1
  3406.     jsr    _LVODisplayAlert(a6)
  3407.     movem.l    (sp)+,d0-d1/a0-a2/a6
  3408.     rts
  3409.  
  3410. *CHECK WHETHER THERE IS ENOUGH STACK FREE    V2.0 *
  3411. ;d0=requested stacksize
  3412. stacktest movem.l    d0-d1/a0-a1,-(sp)
  3413.     move.l    topstack(a5),a0
  3414.     sub.l    sp,a0
  3415.     move.l    a0,d1
  3416.     add.l    d0,d1
  3417.     add.l    #1600,d1    ;allow some bytes for DOS
  3418.     cmp.l    stacksize(a5),d1
  3419.     blo.s    .A
  3420.     lea    stack_tx(pc),a1
  3421.     bsr    pr_stringlf
  3422.     moveq    #-1,d0
  3423.     bra.s    .B
  3424. .A    moveq    #0,d0
  3425. .B    movem.l    (sp)+,d0-d1/a0-a1
  3426.     rts
  3427.  
  3428. bad_number_error
  3429.     moveq    #115,d0
  3430.     bra.s    pr_galactic
  3431.  
  3432. too_less_args
  3433.     moveq    #116,d0
  3434.     bra.s    pr_galactic
  3435.  
  3436. *SendPacket-Error-Tester
  3437. PKTerr    tst.l    sp_res1(a5)
  3438.     bne    .A
  3439.     move.l    sp_res2(a5),d0
  3440.     bra.s    pr_galactic
  3441. .A    rts
  3442. *DOSERRor but Unlock first using D7 as the lock
  3443. DOSerrUL    move.l d7,d1        ;Assume D7=lock
  3444.     beq.s    DOSerr
  3445.     move.l    thistask(a5),a2
  3446.     move.l    pr_Result2(a2),d2
  3447.     jsr    _LVOUnLock(a6)
  3448.     move.l    d2,pr_Result2(a2)
  3449. *DOSERRor handler
  3450. DOSerr    jsr    _LVOIoErr(a6)
  3451.     cmp.l    #232,d0
  3452.     bne.s    pr_galactic
  3453.     moveq    #0,d0
  3454.     rts            ;Return if ERROR_NO_MORE_ENTRIES
  3455.  
  3456. pr_galactic
  3457.     bsr.s    pr_DOSerr    ;entry for dospacket
  3458. galactic
  3459.     move.l    errorstack(a5),sp    ;restore stack
  3460.     moveq    #RETURN_BAD,d0
  3461.     bra    chkfail        ;reenter shell loop
  3462.  
  3463. maybeDOSerr    ;checks if d0=0, then prints DOSerr
  3464.     move.l    d0,-(sp)
  3465.     bne.s    .A
  3466.     jsr    _LVOIoErr(a6)
  3467.     bsr    pr_DOSerr        error occured
  3468. .A    move.l    (sp)+,d0
  3469.     rts
  3470.  
  3471. * ENTRY D0=dos error number
  3472. pr_DOSerr
  3473.     move.l    a2,-(sp)
  3474.     move.l    d0,-(sp)
  3475.     lea    NewPrintBuffer(a5),a2
  3476.     lea    farb2(pc),a1
  3477.     bsr    addstring
  3478.     move.l    parm1(a5),a1
  3479.     bsr    addstring
  3480.     move.b    #":",(a2)+
  3481.     move.b    #" ",(a2)+
  3482.     bsr    GetMessage
  3483.     move.l    a0,a1
  3484.     bsr    addstring
  3485.     lea    farb1(pc),a1
  3486.     bsr    addstring
  3487.     lea    NewPrintBuffer(a5),a1
  3488.     bsr    pr_error
  3489.     tst.l    d0
  3490.     bne.s    .A
  3491.     move.l    #-155,d0
  3492.     bsr    GetMessage
  3493.     move.l    sp,a1
  3494.     bsr    new_print
  3495. .A    lea    lf(pc),a1
  3496.     bsr    pr_error
  3497.     addq.l    #4,sp
  3498.     move.l    (sp)+,a2
  3499.     moveq    #10,d0
  3500.     rts
  3501.  
  3502. pr_error
  3503.     move.l    outhandle(a5),d1
  3504.     move.l    stdout(a5),outhandle(a5)
  3505.     bsr    pr_string
  3506.     move.l    d1,outhandle(a5)
  3507.     rts
  3508.  
  3509. GetMessage
  3510.     cmp.w    #36,kickver(a5)
  3511.     blo.s    .E
  3512.     movem.l    d2-d4,-(sp)    OS2.0+ stuff
  3513.     move.l    d0,d1
  3514.     lea    null(pc),a0
  3515.     move.l    a0,d2
  3516.     lea    gather(a5),a0
  3517.     clr.b    2(a0)
  3518.     move.l    a0,d3
  3519.     moveq    #80,d4
  3520.     jsr    _LVOFault(a6)
  3521.     movem.l    (sp)+,d2-d4
  3522.     lea    gather+2(a5),a0
  3523.     rts
  3524. .E    lea    doserror_text(pc),a0    OS1.3- stuff
  3525.     bra.s    .C
  3526. .B    tst.b    (a0)+
  3527.     bne.s    .B
  3528. .C    move.b    (a0)+,d1
  3529.     beq.s    .A
  3530.     cmp.b    d1,d0
  3531.     bne.s    .B
  3532.     rts
  3533. .A    moveq    #0,d0
  3534.     rts
  3535.  
  3536. * fix up parameters that exist or not
  3537. fixpam32    move.l parm3(a5),d0
  3538.     move.l    d0,a1
  3539.     bne.s    fixpam2
  3540.     lea    null(pc),a1
  3541.     move.l    a1,parm3(a5)
  3542. fixpam2    move.l    parm2(a5),d0
  3543.     move.l    d0,a0
  3544.     bne.s    fxpam
  3545.     lea    null(pc),a0
  3546.     move.l    a0,parm2(a5)
  3547. fxpam    rts
  3548.     
  3549. *************************
  3550. *    RENAME        *
  3551. *************************
  3552. renamez    bsr    fixpam32
  3553. ;DON'T PUT ANYTHING HERE
  3554.     * A0-> oldname  A1-> newname
  3555. rename    move.l    a0,d1
  3556.     move.l    a1,d2
  3557.     jsr    _LVORename(a6)
  3558.     tst.l    d0
  3559.     beq    DOSerr
  3560.     moveq    #RETURN_OK,d0
  3561.     rts
  3562.  
  3563. *************************
  3564. *    MAKEDIR        *
  3565. *************************
  3566. makedirz    lea    parm2(a5),a4
  3567. .A    move.l    (a4)+,d1
  3568.     beq.s    .B
  3569.     bsr.s    mkdir
  3570.     bra.s    .A
  3571. .B    moveq    #RETURN_OK,d0
  3572.     rts
  3573.     
  3574. *MAKEDIR D1-> directory name
  3575. mkdir    jsr    _LVOCreateDir(a6)
  3576.     tst.l    d0
  3577.     beq    DOSerr
  3578.     move.l    d0,d1
  3579.     jsr    _LVOUnLock(a6)
  3580. *    moveq    #0,d0
  3581.     rts
  3582.  
  3583. *************************
  3584. *    PROMPT        *
  3585. *************************
  3586. promptz    tst.l    parm2(a5)
  3587.     beq.s    .B
  3588.     bsr    echoz
  3589.     bsr    pr_lf
  3590.     move.l    parm2(a5),a0
  3591.     lea    prompt_args(a5),a2
  3592.     lea    1(a2),a1
  3593.     moveq    #-1,d0
  3594. .A    addq.b    #1,d0
  3595.     move.b    (a0)+,(a1)+
  3596.     bne.s    .A
  3597. .C    move.b    d0,(a2)
  3598.     MOVEQ    #RETURN_OK,D0
  3599.     rts
  3600. .B    lea    prompt_args+1(a5),a1
  3601.     bsr    pr_stringlf
  3602.     moveq    #RETURN_OK,d0
  3603.     rts
  3604.     
  3605. **************    
  3606. compose_prompt
  3607.     lea    prompt_string(a5),a1
  3608.     move.l    a1,prompt_cr(a5)
  3609.     lea    farb3(pc),a0
  3610. .C    move.b    (a0)+,(a1)+    copy highlight colour
  3611.     bne.s    .C
  3612.     subq.l    #1,a1
  3613.     lea    prompt_args+1(a5),a0
  3614. cpro3    move.b    (a0)+,d0
  3615.     beq    composer3
  3616.     cmp.b    #$5c,d0 ;\
  3617.     bne.s    .A
  3618.     move.b    (a0)+,d0
  3619.     bra    composer2
  3620. .A    cmp.b    #'%',d0
  3621.     bne    composer2
  3622.     move.b    (a0)+,d0
  3623.     bset    #5,d0
  3624.     cmp.b    #'p',d0        check if %p
  3625.     bne.s    try_halfcd
  3626.     lea    CD_string+1(a5),a2
  3627. .B    move.b    (a2)+,(a1)+    copy cd_string to prompt_string
  3628.     bne.s    .B
  3629.     lea    -1(a1),a1
  3630.     bra    cpro3
  3631. try_halfcd
  3632.     cmp.b    #'s',d0        check if %s
  3633.     bne.s    try_line_num
  3634.     lea    CD_string+1(a5),a2
  3635.     move.l    a2,d1
  3636. .A    tst.b    (a2)+
  3637.     bne.s    .A
  3638.     subq.l    #2,a2
  3639.     bra.s    .D
  3640. .C    move.b    -(a2),d0
  3641. .D    cmp.l    a2,d1
  3642.     bhi.s    .E
  3643.     cmp.b    #"/",d0
  3644.     beq.s    .E
  3645.     cmp.b    #":",d0
  3646.     bne.s    .C
  3647. .E    addq.l    #1,a2
  3648. .B    move.b    (a2)+,(a1)+    copy cd_string to prompt_string
  3649.     bne.s    .B
  3650.     lea    -1(a1),a1
  3651.     bra    cpro3
  3652. try_line_num
  3653.     cmp.b    #'l',d0        check if %l
  3654.     bne.s    try_oldcmd
  3655.     move.l    count_line(a5),d0
  3656.     moveq    #0,d1
  3657.     move.l    a1,a2
  3658.     bsr    qdecpr        insert current line number
  3659.     move.l    a2,a1
  3660.     bra    cpro3
  3661. try_oldcmd
  3662.     cmp.b    #'c',d0        check if %c
  3663.     bne.s    try_task_num
  3664.     lea    shelline(a5),a2
  3665. .B    move.b    (a2)+,(a1)+
  3666.     bne.s    .B
  3667.     lea    -1(a1),a1
  3668.     bra    cpro3
  3669. try_task_num
  3670.     cmp.b    #'n',d0        check if %n
  3671.     bne.s    composer2
  3672.     move.l    thistask(a5),a2
  3673.     move.l    pr_TaskNum(a2),d0
  3674.     add.b    #$30,d0
  3675. composer2    move.b    d0,(a1)+
  3676.     cmp.b    #LF,d0
  3677.     bne.s    .A
  3678.     move.l    a1,prompt_cr(a5)
  3679. .A    bra    cpro3
  3680. composer3    lea    farb1(pc),a0
  3681. .A    move.b    (a0)+,(a1)+
  3682.     bne.s    .A
  3683.     rts
  3684.  
  3685.     
  3686. *FILL FIB WITH EXAMINE A0-> directory name ,D7=filelock on return
  3687. fibexam    move.l    a0,-(sp)
  3688.     moveq    #ACCESS_READ,d2
  3689.     move.l a0,d1
  3690.     jsr    _LVOLock(a6)
  3691.     move.l    d0,d7
  3692.     beq    DOSerr
  3693.     bsr    fibexam2
  3694.     move.l    (sp)+,a0
  3695.     rts
  3696. fibexam2
  3697.     move.l    d0,d1
  3698.     move.l    a5,d2
  3699.     jsr    _LVOExamine(a6)
  3700.     tst.l    d0
  3701.     beq    DOSerrUL
  3702.     rts
  3703.  
  3704. *****************
  3705. *    CD    *
  3706. *****************
  3707. cdz    tst.l    parm2(a5)
  3708.     beq    querycd
  3709.     move.l    parm2(a5),a0
  3710.     bsr    fibexam
  3711.     tst.l    fib_DirEntryType(a5)    ;check entry OK
  3712.     bpl.s    .A
  3713.     move.l    d7,d1
  3714.     jsr    _LVOUnLock(a6)
  3715.     move.l    #212,d0
  3716.     bra    pr_galactic
  3717. .A    move.l    d7,d1
  3718. *CHANGE DIRECTORY d1:lock to new current directory
  3719. chdir    move.l    d1,a0
  3720.     add.l    a0,a0
  3721.     add.l    a0,a0
  3722.     move.l    thistask(a5),a1
  3723.     move.l    fl_Task(a0),pr_FileSystemTask(a1)
  3724.     jsr    _LVOCurrentDir(a6)
  3725.     move.l    cdback(a5),d1
  3726.     move.l    d0,cdback(a5)    remember old directory
  3727.     jsr    _LVOUnLock(a6)    unlock the old directory
  3728.     bsr    eval_CD        update cd string
  3729.     moveq    #RETURN_OK,d0
  3730.     rts
  3731.     
  3732. querycd    bsr    eval_CD
  3733.     lea    CD_string+1(a5),a1
  3734.     bsr    pr_stringlf
  3735.     moveq    #RETURN_OK,d0
  3736.     rts
  3737.  
  3738.  
  3739. ** Evaluate entire name of current directory and put in CD_string
  3740. eval_CD    clr.b    CD_string+1(a5)
  3741.     lea    null(pc),a0
  3742.     move.l    a0,d1
  3743.     moveq    #ACCESS_READ,d2
  3744.     jsr    _LVOLock(a6)
  3745.     tst.l    d0
  3746.     beq.s    .A
  3747.     move.l    d0,a0
  3748.     add.l    a0,a0
  3749.     add.l    a0,a0
  3750.     move.l    fl_Key(a0),cd_block(a5)
  3751.     move.l    fl_Volume(a0),cd_volnode(a5)
  3752.     lea    CD_string+1(a5),a0
  3753.     bsr    eval_full_path
  3754.     jsr    _LVOUnLock(a6)
  3755. .A    moveq    #-1,d0
  3756.     lea    CD_string(a5),a0
  3757.     lea    1(a0),a1
  3758. .B    addq.b    #1,d0
  3759.     tst.b    (a1)+
  3760.     bne.s    .B
  3761.     move.b    d0,(a0)
  3762.     rts
  3763.     
  3764. ** evaluate entire name associated with lock in D0, store string in A0
  3765. ** Return D1 = last lock to unlock
  3766. ** Reg usage: d0,d1,d2,d3,a0,a1,a3 (must not use A2)
  3767. eval_full_path
  3768.     move.b    #"?",(a0)
  3769.     clr.b    1(a0)
  3770.     move.l    d0,d1
  3771.     beq.s    .C
  3772.     lsl.l    #2,d0
  3773.     move.l    d0,a1
  3774.     moveq    #ACCESS_READ,d0
  3775.     cmp.l    fl_Access(a1),d0    only eval read locks
  3776.     bne.s    .B
  3777. .C    cmp.w    #36,kickver(a5)
  3778.     blo.s    .A
  3779.     move.l    d1,a3
  3780.     move.l    a0,d2
  3781.     moveq    #78,d3
  3782.     jsr    _LVONameFromLock(a6)
  3783.     move.l    a3,d1
  3784. .B    rts
  3785. .A    lea    -88(sp),sp
  3786.     move.l    a0,4(sp)        save address of string
  3787.     move.l    d1,(sp)        save original lock on stack
  3788.     move.l    a5,d2
  3789.     jsr    _LVOExamine(a6)
  3790.     move.l    4(sp),a1
  3791.     lea    fib_FileName(a5),a0
  3792. evx1    move.b    (a0)+,(a1)+    COPY FILENAME TO deststring
  3793.     bne.s    evx1
  3794.     lea    -1(a1),a3
  3795. evcd2    move.l    (sp),d1        get lock
  3796.     jsr    _LVOParentDir(a6)
  3797.     tst.l    d0
  3798.     beq.s    root_found
  3799.     move.l    (sp),d1
  3800.     move.l    d0,(sp)
  3801.     jsr    _LVOUnLock(a6)    unlock last
  3802.     move.l    (sp),d1
  3803.     move.l    a5,d2
  3804.     jsr    _LVOExamine(a6)
  3805.     lea    fib_FileName(a5),a0
  3806.     lea    8(sp),a1
  3807. evx2    move.b    (a0)+,(a1)+    stackbuf = filename
  3808.     bne.s    evx2
  3809.     move.b    #'/',-1(a1)
  3810.     move.l    4(sp),a0
  3811. evx3    move.b    (a0)+,(a1)+    stackbuf = filename/CD_string
  3812.     bne.s    evx3
  3813.     move.l    4(sp),a1
  3814.     lea    8(sp),a0
  3815. evx4    move.b    (a0)+,d0
  3816.     move.b    d0,(a1)+
  3817.     cmp.b    #'/',d0
  3818.     bne.s    evx4
  3819.     lea    -1(a1),a3
  3820. evx5    move.b    (a0)+,(a1)+    dest string = stackbuf
  3821.     bne.s    evx5
  3822.     bra    evcd2
  3823. root_found
  3824.     move.l    (sp),d1
  3825.     tst.b    (a3)
  3826.     bne.s    root2
  3827.     clr.b    1(a3)
  3828. root2    move.b    #':',(a3)
  3829.     lea    88(sp),sp
  3830.     rts
  3831.  
  3832. *ADDPATH A0-> path  A1-> parameter  A2-> destination for string
  3833. ** eg. (A0)='df0:libs',0  (A1)='arp.library',0  (A2)='df0:libs/arp.library',0
  3834. addpath    movem.l a0-a2,-(sp)
  3835.     move.b (a0),d0
  3836.     beq.s addp4
  3837. addp1    move.b (a0)+,d0
  3838.     beq.s addp2
  3839.     move.b d0,(a2)+
  3840.     bra.s addp1
  3841. addp2    move.b -2(a0),d0
  3842.     cmp.b #':',d0
  3843.     beq.s addp4
  3844.     cmp.b #'/',d0
  3845.     beq.s addp4
  3846.     move.b #'/',(a2)+
  3847. addp4    move.l a1,a0
  3848.     move.l a2,a1
  3849.     bsr cp_string
  3850.     movem.l (sp)+,a0-a2
  3851.     rts
  3852.  
  3853.  
  3854. * Search Resident list for command    V2.0:Global resi's
  3855. * RETURN D0=seglist OR 0 if not found
  3856. *    A0=addr of node        D2=addr of Vorgänger
  3857. search_res    move.l    parm1(a5),a4
  3858. search_res2
  3859.     bsr    resi_hand
  3860.     beq.s    .D
  3861.     move.l    a0,d2
  3862. .A    lsl.l    #2,d0
  3863.     move.l    a4,a1            string
  3864.     move.l    d0,a2
  3865.     lea    resi_name(a2),a0    BSTR
  3866.     moveq    #0,d3
  3867.     move.b    (a0)+,d3
  3868.     subq.w    #1,d3
  3869. .B    move.b    (a0)+,d0
  3870.     move.b    (a1)+,d1
  3871.     cmp.b    ctrl_codes+15(a5),d1
  3872.     bne.s    .F
  3873.     tst.b    (a1)
  3874.     beq.s    .C
  3875. .F    bsr    compD1D0nocase
  3876.     dbne    d3,.B
  3877.     bne.s    .E    not equal
  3878.     tst.b    (a1)
  3879.     beq.s    .C    the (null-)END
  3880. .E    move.l    a2,d2
  3881.     move.l    resi_link(a2),d0    get link
  3882.     bne.s    .A
  3883. .D    moveq    #0,d0
  3884.     rts
  3885. .C    moveq    #-1,d1
  3886.     cmp.l    resi_usecount(a2),d1    is it a system-resi ?
  3887.     beq.s    .D
  3888.     move.l    resi_seglist(a2),d0    get seglist
  3889.     move.l    a2,a0
  3890.     rts
  3891.  
  3892.  
  3893. *Search paths for command
  3894. *Exit: d0=seglist, d4=PROGDIR:, branches if script file
  3895. spaths    move.l    parm1(a5),a4    A4=parm1
  3896. spaths2    moveq    #0,d4    jump-in for resident,do not load scripts with it!
  3897.     move.l    thistask(a5),a3
  3898.     lea    pr_CurrentDir(a3),a3    (A3)=ptr to current dir
  3899.     move.l    (a3),d3            d3=current dir at beginning
  3900.     move.l    d3,d4            d4=PROGDIR:
  3901.     bsr    lock_or_load
  3902.     tst.l    d0
  3903.     bmi.s    .C        not found
  3904.     bne    gotit        found & executable
  3905.     tst.b    forcediskflag(a5)
  3906.     bne.s    .C        do not change dir
  3907.     tst.l    fib_DirEntryType(a5)    is it a DIR ?
  3908.     bmi    s_flagset    no, exec script ?
  3909.     addq.l    #4,sp        return from archie3
  3910.     move.l    a4,d1
  3911.     moveq    #ACCESS_READ,d2
  3912.     jsr    _LVOLock(a6)    change current dir
  3913.     move.l    d0,d1
  3914.     bra    chdir
  3915.  
  3916. .C    move.l    a4,a0
  3917. .F    move.b    (a0)+,d0    are there path-specific chars in the name
  3918.     cmp.b    #"/",d0
  3919.     beq.s    no_more_paths
  3920.     cmp.b    #":",d0
  3921.     beq.s    no_more_paths
  3922.     tst.b    d0
  3923.     bne.s    .F
  3924.     moveq    #-1,d1
  3925.     bsr    changeWindowPtr        no requesters
  3926.     move.l    CLIptr(a5),a2
  3927.     lea    cli_CommandDir(a2),a2    A2=ptr to current path
  3928.  
  3929. .A    move.l    (a2),d0        search all paths
  3930.     beq.s    no_more_paths
  3931.     lsl.l    #2,d0
  3932.     move.l    d0,a2
  3933.     move.l    4(a2),d4    d4=PROGDIR:
  3934.     beq.s    .A
  3935.     move.l    d4,(a3)
  3936.     bsr    lock_or_load    disk access
  3937.     tst.l    d0
  3938.     bmi.s    .A
  3939.     bne.s    gotit
  3940.     tst.l    fib_DirEntryType(a5)    is it a DIR ?
  3941.     bpl.s    .A
  3942.     bra.s    s_flagset    exec script
  3943. no_more_paths
  3944.     moveq    #0,d0
  3945. gotit    move.l    d3,(a3)        restore current dir
  3946.     moveq    #0,d1        requesters on
  3947.     bra    changeWindowPtr
  3948.  
  3949. lock_or_load
  3950.     move.l    a4,d1
  3951.     moveq    #ACCESS_READ,d2
  3952.     jsr    _LVOLock(a6)
  3953.     move.l    d0,d7
  3954.     bne.s    .A
  3955.     moveq    #-1,d0        file not found
  3956.     rts
  3957. .A    bsr    fibexam2
  3958.     moveq    #0,d0
  3959.     tst.l    fib_DirEntryType(a5)
  3960.     bpl.s    .C
  3961.     move.l    fib_Protection(a5),d1
  3962.     btst    #6,d1    script-bit ?
  3963.     bne.s    .C
  3964.     btst    #1,d1    not-execute-bit ?
  3965.     bne.s    .C
  3966.     move.l    a4,d1
  3967.     jsr    _LVOLoadSeg(a6)
  3968. .C    move.l    d0,-(sp)
  3969.     move.l    d7,d1
  3970.     jsr    _LVOUnLock(a6)
  3971.     move.l    (sp)+,d0
  3972.     rts
  3973.  
  3974. s_flagset
  3975.     move.l    d3,(a3)        restore current dir
  3976.     moveq    #0,d1        requesters on
  3977.     bsr    changeWindowPtr
  3978.     addq.l    #4,sp    kill return addresses (archie3,spaths)
  3979.     move.l    fib_Protection(a5),d1
  3980.     btst    #6,d1
  3981.     beq.s    .A
  3982.     addq.l    #4,sp    kill return addresses (archie3,spaths)
  3983.     move.l    a4,a0    A4 pts to filename
  3984.     bsr    readfile
  3985.     move.l    d3,(a3)        restore current dir
  3986.     bra    xz3
  3987. .A    move.l    #305,d0
  3988.     btst    #1,d1
  3989.     bne    pr_DOSerr    not-execute-bit
  3990. ;show ascii or amigaguide text
  3991.     move.l    4.w,a6
  3992.     lea    guidename(pc),a1
  3993.     jsr    _LVOOldOpenLibrary(a6)
  3994.     tst.l    d0
  3995.     beq.s    .C        opened amigaguide.library ?
  3996.     move.l    d0,a6
  3997.     moveq    #NewAmigaGuide_SIZEOF/4-1,d0
  3998. .D    clr.l    -(sp)
  3999.     dbra    d0,.D
  4000.     move.l    a4,nag_Name(sp)    filename into nag
  4001.     move.l    sp,a0        nag to a0
  4002.     sub.l    a1,a1        must be zero
  4003.     jsr    _LVOOpenAmigaGuideA(a6)    open guide
  4004.     tst.l    d0
  4005.     beq.s    .B        failed to open guide ?
  4006.     move.l    d0,a0
  4007.     jsr    _LVOCloseAmigaGuide(a6)    wait till user closes guide
  4008. .B    lea    NewAmigaGuide_SIZEOF(sp),sp
  4009.     move.l    a6,a1        Free library
  4010.     move.l    4.w,a6
  4011.     jsr    _LVOCloseLibrary(a6)
  4012. .C    move.l    dosbase(a5),a6
  4013.     rts
  4014.  
  4015.  
  4016. * ARCHIE 3 calls system0 to execute non internal commands
  4017. archie3    tst.l    parm1(a5)        exit if nothing typed
  4018.     beq    noarch31
  4019.     clr.b    resi_flag(a5)        =0 if resident
  4020.     bsr    search_res        search resident list first
  4021.     tst.l    d0
  4022.     bne.s    .A
  4023.     addq.b    #1,resi_flag(a5)    =1 if not resident
  4024.     bsr    spaths            load the command
  4025.     tst.l    d0
  4026.     beq    noarch32        could not load
  4027.     cmp.w    #36,kickver(a5)
  4028.     blo.s    .A
  4029.     move.l    thistask(a5),a3
  4030.     move.l    d4,pr_HomeDir(a3)    init PROGDIR:
  4031. .A    move.l    d0,temp1(a5)        save the segment
  4032.     bsr    raw_off
  4033.     bsr    save_mem_time
  4034.     lea    CLIbuf(a5),a0
  4035.     move.l    a0,-(sp)    push arg_args ptr.
  4036.     move.l    d0,-(sp)    push seglist
  4037.     move.l    parm1(a5),d0
  4038.     move.l    d0,-(sp)    push arg_name
  4039.     bsr    _System0    TAKES 3 PARMS(ARG_NAME,SEGLIST,ARGS)
  4040.     lea    12(sp),sp
  4041.     move.l    d0,-(sp)
  4042.     cmp.w    #36,kickver(a5)
  4043.     blo.s    .G
  4044.     move.l    thistask(a5),a3
  4045.     clr.l    pr_HomeDir(a3)        reset PROGDIR:
  4046. .G    jsr    _LVOIoErr(a6)
  4047.     move.l    d0,Result2(a5)
  4048.     btst    #FLcheck,Flags+3(a5)
  4049.     beq.s    .C
  4050.     bsr    show_status
  4051. .C    tst.b    resi_flag(a5)
  4052.     beq.s    .B
  4053.     move.l    better_Seglist(a5),d1
  4054.     jsr    _LVOUnLoadSeg(a6)
  4055. .B    bsr    raw_on
  4056.     move.l    (sp)+,d2    RESULT IN D2
  4057.     beq.s    .D
  4058.     btst    #FLerrors,Flags+3(a5)
  4059.     beq.s    .D
  4060.     move.l    Result2(a5),d0
  4061.     beq.s    .D
  4062.     bsr    pr_DOSerr    if result > 0 print error
  4063. .D    move.l    d2,d0    
  4064. noarch31    rts
  4065. noarch32
  4066.     moveq    #-121,d0        command not found
  4067.     bsr    pr_DOSerr
  4068.     moveq    #RETURN_BAD,d0        return d0 bad
  4069.     rts
  4070.  
  4071.  
  4072. *****    SYSTEM0 execute command from disk from Sozobon C distribution.
  4073. _System0
  4074.     movem.l    d2-d3/a2-a6,-(sp)    ;SAVED_REGS
  4075.     moveq    #NO_CLI,REG_Result      ;#-1,d3 ERROR - not a CLI task
  4076.     move.l    4.w,REG_SysBase    ;4,a6
  4077.     move.l    thistask(a5),REG_Process    ;a2
  4078.     move.l    pr_CLI(REG_Process),d0
  4079.     beq    quit0
  4080.  
  4081. * build local stack frame & save some values
  4082.     lsl.l    #2,d0
  4083.     move.l    d0,REG_CLI    ;a3
  4084.     move.l    sp,REG_PrevStack        ;a1 save old stack pointer
  4085.     move.l    sp,d0
  4086.     and.b    #$fc,d0 ;make SP longword-aligned for BPTRs
  4087.     move.l    d0,sp
  4088.     sub.l    #sf_SIZEOF,sp    ;stack-frame-struct
  4089.     move.l    REG_PrevStack,sf_PrevStack(sp)
  4090.     move.l    REG_Process,sf_Process(sp)
  4091.     move.l    REG_CLI,sf_CLI(sp)
  4092.     move.l  pr_ReturnAddr(REG_Process),sf_SaveReturnAddr(sp)
  4093.  
  4094. * allocate space for stack
  4095.     moveq    #NO_MEM,REG_Result    ;ERROR - no memory for STACK
  4096.     move.l    cli_DefaultStack(REG_CLI),d0    ;in longwords for "VEC"
  4097.     lsl.l    #2,d0
  4098.     move.l    d0,sf_PushSize(sp)
  4099.     addq.l    #4,d0    ;one additional longword
  4100.     move.l    d0,sf_StackSize(sp)
  4101.     moveq    #1,d1    ;intentionally NOT "MEMF_PUBLIC"!; V2.0 Why not ?
  4102.     callsys    AllocMem
  4103.     tst.l    d0
  4104.     beq    quit1
  4105.     move.l    d0,sf_StackBase(sp)    ;save result
  4106.  
  4107. * save old command pointer, build new BCPL command name
  4108.     move.l    cli_CommandName(REG_CLI),sf_SaveCommandName(sp)
  4109.     move.l    sf_PrevStack(sp),REG_PrevStack
  4110.     move.l    ARG_NAME(REG_PrevStack),a0 ;first parameter to "System0()"
  4111.     lea    sf_CommandName(sp),a1 ;BSTR
  4112.     move.w    #MAXBSTR-2,d0
  4113.     bsr    cpBSTR
  4114.     move.l    d0,cli_CommandName(REG_CLI)
  4115. * save contents of Current Input Stream
  4116.     move.l    pr_CIS(REG_Process),d0
  4117.     lsl.l    #2,d0
  4118.     move.l    d0,REG_CIS
  4119.     move.l    REG_CIS,sf_CIS(sp)
  4120.     move.l    fh_Buf(REG_CIS),sf_SCB_Buf(sp)
  4121.     move.l    fh_Pos(REG_CIS),sf_SCB_Pos(sp)
  4122.     move.l    fh_End(REG_CIS),sf_SCB_End(sp)
  4123. tst
  4124. * convert argument to LF-terminated string
  4125.     move.l    sf_PrevStack(sp),REG_PrevStack
  4126.     move.l    ARG_ARGS(REG_PrevStack),a0 ;third argument to "System0()"
  4127.     lea    sf_CommandArgs(sp),a1    ;first buffer location
  4128.     move.l    a1,d0
  4129.     lsr.l    #2,d0
  4130.     move.l    d0,fh_Buf(REG_CIS)
  4131.     move.w    #MAXBSTR-1,d0    ;leave some room for terminating LF
  4132.     bra.s    .D
  4133. .C    move.b    d1,(a1)+
  4134. .D    move.b    (a0)+,d1
  4135.     dbeq    d0,.C
  4136.     move.b    #LF,(a1)
  4137.     move.l    sf_PrevStack(sp),REG_PrevStack
  4138.     sub.l    ARG_ARGS(REG_PrevStack),a0    ;subtract first position
  4139.     move.l    a0,d0    ;do NOT subtract 1, LF need this byte
  4140. * setup start/end indices in Stream Control Block
  4141.     clr.l   fh_Pos(REG_CIS)
  4142.     move.l  d0,fh_End(REG_CIS)
  4143.  
  4144. * misc setup
  4145.     clr.l    pr_Result2(REG_Process)    ;clear secondary result
  4146.     move.l    a5,sf_Membase(sp)    ;save membase
  4147. ;    moveq    #0,d0
  4148. ;    moveq    #0,d1
  4149. ;    bset    #SIGBREAKB_CTRL_C,d1
  4150. ;    callsys    SetSignal    ;clear CTRL-C flag
  4151.  
  4152. * handle seglist and start address
  4153.     move.l    cli_Module(REG_CLI),sf_SaveModule(sp)
  4154.     move.l    sf_PrevStack(sp),REG_PrevStack
  4155.     move.l    ARG_SEGLIST(REG_PrevStack),d0 ;second argument to "System0()"
  4156.     move.l    d0,cli_Module(REG_CLI)
  4157.     lsl.l    #2,d0
  4158.     move.l    d0,a3
  4159. * setup processor registers & C-interface
  4160.     lea    sf_CommandArgs(sp),a0
  4161.     move.l    fh_End(REG_CIS),d0
  4162. * setup processor registers, BCPL-interface, stack & return address for "Exit()"
  4163.     move.l    sf_StackBase(sp),a1    ;BCPL stack, low end
  4164.     move.l    sf_PushSize(sp),d2
  4165.     lea    4(a1,d2.l),a4    ;must not destroy REG_Process!
  4166.     move.l    sp,-(a4)    ;previous stack frame
  4167.     move.l    d2,-(a4)    :stack size in bytes
  4168.     move.l    a4,pr_ReturnAddr(REG_Process)
  4169.     move.l    a4,sp
  4170.     move.l    dosbase(a5),a4    ;V2.0 small data
  4171.     movem.l    dl_A2(a4),a2/a5/a6
  4172.  
  4173. * now call the command at its entry point
  4174.     jsr    4(a3)    ;code starts one longword behind segment pointer
  4175.     move.l    d0,REG_Result    ;save return code
  4176.  
  4177. * get old stackframe & reload old register contents
  4178.     move.l    4(sp),sp    ;old stack frame
  4179.     move.l    sf_Membase(sp),a5
  4180.     move.l    sf_Process(sp),a0
  4181.     move.l    sf_SaveReturnAddr(sp),pr_ReturnAddr(a0)
  4182.     move.l    sf_CIS(sp),d0
  4183.     move.l    d0,a1
  4184.     lsr.l    #2,d0
  4185.     move.l    d0,pr_CIS(a0)    ;V2.0 restore CIS
  4186.     move.l    sf_CLI(sp),a0
  4187.     move.l    sf_SaveCommandName(sp),cli_CommandName(a0)
  4188. * Next line makes powerpacker programs deallocate memory properly
  4189.     move.l    cli_Module(a0),better_Seglist(a5)    ;V2.0 small data
  4190.     move.l    sf_SaveModule(sp),cli_Module(a0)
  4191. * restore original contents of Current Input Stream
  4192.     move.l    sf_CIS(sp),a0
  4193.     lea    sf_CommandArgs(sp),a1
  4194.     move.l    a1,d0
  4195.     lsr.l    #2,d0
  4196.     cmp.l    fh_Buf(a0),d0    ;still the same?
  4197.     bne.s    .E    ;no: don't restore
  4198.     move.l    sf_SCB_Buf(sp),fh_Buf(a0)
  4199. .E    move.l    sf_SCB_Pos(sp),fh_Pos(a0)
  4200.     tst.l    fh_End(a0)    ;end index set?
  4201.     beq.s    .F    ;no: don't restore
  4202.     move.l    sf_SCB_End(sp),fh_End(a0)
  4203.  
  4204. * free temporary stack
  4205. .F    move.l    4.w,REG_SysBase
  4206.     move.l    sf_StackBase(sp),a1
  4207.     move.l    sf_StackSize(sp),d0
  4208.     callsys    FreeMem
  4209.  
  4210. quit1    move.l    sf_PrevStack(sp),sp    ;UNLINK local variables
  4211. quit0    move.l    REG_Result,d0
  4212.     movem.l    (sp)+,d2-d3/a2-a6    ;SAVED_REGS
  4213. quitx    rts
  4214.  
  4215.  
  4216. *************************
  4217. *    HELP        *
  4218. *************************
  4219. helpz    bsr    rawh_off
  4220.     move.l    parm2(a5),d7
  4221.     bne    help_man
  4222.     lea    helptx1(pc),a1
  4223.     bsr    pr_stringlf
  4224.     lea    comtext(pc),a4
  4225.     lea    tempbuf(a5),a3
  4226. .D    moveq    #5,d3
  4227. .C    move.l    a3,a2
  4228.     tst.b    (a4)        
  4229.     beq    .E
  4230.     moveq    #12,d2
  4231. .B    subq.l    #1,d2
  4232.     move.b    (a4)+,(a2)+
  4233.     bne.s    .B
  4234.     tst.b    -(a2)    bump    back
  4235. .A    move.b    #$20,(a2)+
  4236.     dbra    d2,.A
  4237.     clr.b    (a2)
  4238.     move.l    a3,a1
  4239.     bsr    pr_string
  4240.     dbra    d3,.C
  4241.     bsr    pr_lf
  4242.     bra    .D
  4243. .E    bsr    pr_lf
  4244.     lea    helptx2(pc),a4
  4245.     lea    helptx3(pc),a0
  4246.     move.l    a0,d6
  4247.     bsr    pr_screen
  4248.     moveq    #RETURN_OK,D0
  4249.     rts
  4250.  
  4251. * print out part of manual, d7 points to topic
  4252. help_man lea    manadr(pc),a2    global variable
  4253.     move.l    4(a2),d1
  4254.     move.l    (a2),d0
  4255.     bne.s    .A
  4256.     lea    helpld(pc),a1
  4257.     bsr    pr_string
  4258.     bsr    pr_lf
  4259.     lea    helpman(pc),a0
  4260.     bsr    readfile    load manual
  4261.     move.l    d0,(a2)        manadr
  4262.     move.l    d1,4(a2)    mansize
  4263. .A    move.l    d0,a3
  4264.     move.l    d1,d5
  4265.     add.l    a3,d5
  4266.     move.l    a3,a2
  4267.     move.l    d7,a1        type all ?
  4268.     moveq    #0,d4
  4269.     cmp.b    #"?",(a1)
  4270.     beq    make_screen    type all !
  4271. .B    move.l    d7,a1
  4272.     move.l    d5,a0
  4273.     addq.l    #1,a2
  4274.     bsr    searchSTR    search topic in manual
  4275.     cmp.b    #LF,d0
  4276.     bne.s    .C
  4277.     cmp.b    #"=",-6(a2)    there must be a lot of "=" before topic
  4278.     bne.s    .B
  4279.     cmp.b    #"=",-7(a2)    leave room for underlined sequence
  4280.     bne.s    .B
  4281.     move.l    a1,d4
  4282. .E    bsr    check_c        ctrl-c ?
  4283.     bne.s    .C
  4284. .D    cmp.l    d5,a1
  4285.     bhi.s    .C
  4286.     cmp.b    #LF,(a1)+    print lines separately
  4287.     bne.s    .D
  4288.     move.l    d4,d2
  4289.     move.l    a1,d3
  4290.     sub.l    d2,d3
  4291.     move.l    a1,d4
  4292.     move.l    outhandle(a5),d1
  4293.     jsr    _LVOWrite(a6)
  4294.     move.l    d4,a1
  4295.     cmp.b    #"=",-2(a1)    search next lot of "="
  4296.     bne.s    .E
  4297.     cmp.b    #"=",-3(a1)
  4298.     bne.s    .E
  4299.     bra.s    .B        another fitting topic ?
  4300. .C    moveq    #RETURN_OK,D0
  4301.     rts
  4302.  
  4303. giveman    movem.l    d0/d1/a0/a1,-(sp)    free manual-memory
  4304.     lea    manadr(pc),a0
  4305.     tst.l    (a0)
  4306.     beq.s    .A
  4307.     move.l    (a0),a1
  4308.     clr.l    (a0)
  4309.     move.l    4(a0),d0
  4310.     bsr    givemem
  4311. .A    movem.l    (sp)+,d0/d1/a0/a1
  4312.     rts
  4313.  
  4314.  
  4315. * PRINT A STRING BUT PUT A LINEFEED AFTER IT
  4316. pr_stringlf    bsr pr_string
  4317.         bra pr_lf
  4318.  
  4319. *****************    
  4320. *    PATH    *     Assign path or show it.
  4321. *****************
  4322. pathz    lea    parm2(a5),a3
  4323.     move.l    (a3),d0        see whether any parameters
  4324.     beq    ShowPaths
  4325.     move.l    CLIptr(a5),a4
  4326.     lea    cli_CommandDir(a4),a4
  4327.     move.l    d0,a0
  4328.     bsr    return_dash_option
  4329.     cmp.b    #"C",d0
  4330.     bne.s    .F
  4331.     bsr    DeletePaths    * remove all paths
  4332.     addq.l    #4,a3
  4333.  
  4334. .F    moveq    #-1,d3        reverse order
  4335. .G    addq.l    #1,d3
  4336.     tst.l    (a3)+
  4337.     bne.s    .G
  4338.     subq.l    #4,a3
  4339.     bra.s    .D
  4340. .C    move.l    -(a3),d1
  4341.     moveq    #ACCESS_READ,d2    * add as many paths as given
  4342.     jsr    _LVOLock(a6)    get a lock
  4343.     move.l    d0,d2
  4344.     beq    DOSerr
  4345.     bsr    CreatePath
  4346.     beq    resi_no_mem
  4347. .D    dbra    d3,.C
  4348.     moveq    #RETURN_OK,d0
  4349.     rts
  4350.  
  4351. DeletePaths    ;a4=cli_CommandDir, removes all paths
  4352.     move.l    a2,-(sp)
  4353.     move.l    a4,a2
  4354. .A    move.l    (a2),d0
  4355.     beq.s    .B
  4356.     lsl.l    #2,d0
  4357.     move.l    d0,a2
  4358.     move.l    4(a2),d1
  4359.     beq.s    .A
  4360.     jsr    _LVOUnLock(a6)    unlock all paths
  4361.     bra.s    .A
  4362. .B    move.l    (a4),d1
  4363.     beq.s    .E
  4364.     jsr    _LVOUnLoadSeg(a6)    free memory
  4365.     tst.l    d0
  4366.     beq    DOSerr
  4367.     clr.l    (a4)        set path ptr to nil
  4368. .E    move.l    (sp)+,a2
  4369.     rts
  4370.  
  4371. CreatePath    ;d2=Lock, a4=cli_CommandDir
  4372.     moveq    #12,d0
  4373.     moveq    #1,d1
  4374.     bsr    iwantmem    create seglist
  4375.     beq.s    .A
  4376.     move.l    d0,a0
  4377.     addq.l    #4,d0
  4378.     lsr.l    #2,d0
  4379.     moveq    #12,d1
  4380.     move.l    d1,(a0)        size of seglist
  4381.     move.l    (a4),4(a0)    link the new path
  4382.     move.l    d2,8(a0)    bptr to lock
  4383.     move.l    d0,(a4)        first in path-list
  4384. .A    rts
  4385.  
  4386. ShowPaths
  4387.     bsr    rawh_off
  4388.     move.l    #-152,d0
  4389.     bsr    GetMessage
  4390.     move.l    a0,a1
  4391.     bsr    pr_stringlf
  4392.     move.l    CLIptr(a5),a0
  4393.     lea    cli_CommandDir(a0),a2
  4394. .A    move.l    (a2),d0
  4395.     beq.s    .B
  4396.     lsl.l    #2,d0
  4397.     move.l    d0,a2
  4398.     move.l    4(a2),d1
  4399.     beq.s    .A
  4400.     jsr    _LVODupLock(a6)
  4401.     tst.l    d0
  4402.     beq.s    .A
  4403.     lea    tempbuf(a5),a0
  4404.     bsr    eval_full_path
  4405.     jsr    _LVOUnLock(a6)
  4406.     lea    tempbuf(a5),a1
  4407.     bsr    pr_stringlf
  4408.     bra.s    .A
  4409. .B    moveq    #RETURN_OK,d0
  4410.     rts
  4411.  
  4412. CopyPaths    ;copy paths from task in a0 to this task
  4413.     movem.l    d2-d3/a2-a4,-(sp)
  4414.     move.l    thistask(a5),a4
  4415.     move.l    pr_CLI(a4),d0
  4416.     beq.s    .D
  4417.     lsl.l    #2,d0
  4418.     move.l    d0,a4
  4419.     lea    cli_CommandDir(a4),a4
  4420.     move.l    pr_CLI(a0),d0
  4421.     beq.s    .D
  4422.     lsl.l    #2,d0
  4423.     move.l    d0,a0
  4424.     lea    cli_CommandDir(a0),a2
  4425.     lea    tempbuf(a5),a3
  4426.     moveq    #0,d3
  4427. .A    move.l    (a2),d0        * walk through all paths
  4428.     beq.s    .C
  4429.     lsl.l    #2,d0
  4430.     move.l    d0,a2
  4431.     move.l    4(a2),d1
  4432.     beq.s    .A
  4433.     move.l    d1,(a3)+
  4434.     addq.l    #1,d3
  4435.     bra.s    .A
  4436. .B    move.l    -(a3),d1
  4437.     jsr    _LVODupLock(a6)    copy lock
  4438.     move.l    d0,d2
  4439.     beq.s    .C
  4440.     bsr    CreatePath    add path
  4441. .C    dbra    d3,.B
  4442. .D    movem.l    (sp)+,d2-d3/a2-a4    return
  4443.     rts
  4444.  
  4445. *****************
  4446. *    INFO    *
  4447. *****************
  4448. infoz    bsr    rawh_off        ;V2.0 (fully new)
  4449.     lea    inform_tx(pc),a1
  4450.     bsr    pr_stringlf
  4451.     move.l    $22(a6),a0    ;rootnode
  4452.     move.l    $18(a0),a0    ;dosinfo
  4453.     add.l    a0,a0
  4454.     add.l    a0,a0
  4455.     move.l    4(a0),d6    ;devicelist
  4456. jajo    tst.l    d6
  4457.     bne    .B
  4458.     moveq    #RETURN_OK,d0
  4459.     rts
  4460.  
  4461. .B    lsl.l    #2,d6    ;BPTR
  4462.     move.l    d6,a4
  4463.     move.l    (a4),d6        ;next
  4464.     tst.l    4(a4)        ;type
  4465.     bne.s    jajo    ;was volume or assign
  4466.     tst.l    8(a4)        ;task
  4467.     beq.s    jajo    ;was non-disk-device
  4468. didev    move.l    $28(a4),a0    ;name
  4469.     add.l    a0,a0
  4470.     add.l    a0,a0
  4471.     moveq    #0,d0
  4472.     move.b    (a0)+,d0
  4473.     lea    tempbuf(a5),a3
  4474.     move.l    a3,a2
  4475.     bra.s    .D
  4476. .C    move.b    (a0)+,(a2)+
  4477. .D    dbra    d0,.C
  4478.     move.b    #":",(a2)+
  4479.     clr.b    (a2)
  4480.     move.l    8(a4),packettask(a5)    ;aptr task
  4481.     bsr    GetDiskInfo
  4482.     bsr    PKTerr
  4483.     bsr    do_forbid
  4484.     move.l    id_DiskType(a5),d1
  4485.     move.l    d1,d0
  4486.     clr.b    d0
  4487.     cmp.l    #"DOS"<<8,d0
  4488.     beq.s    itsDos        ;DOS-Disk
  4489.     move.l    #226,d0
  4490.     moveq    #-1,d2
  4491.     cmp.l    d1,d2
  4492.     beq.s    .F
  4493.     subq.l    #1,d0
  4494.     cmp.l    #"BAD"<<8,d1
  4495.     beq.s    .F
  4496.     cmp.l    #"NDOS",d1
  4497.     beq.s    .F
  4498.     lea    kickdisk(pc),a0
  4499.     cmp.l    #"KICK",d1
  4500.     beq.s    .G
  4501.     move.l    #213,d0
  4502. .F    bsr    GetMessage
  4503. .G    move.l    a0,-(sp)
  4504.     move.l    id_UnitNumber(a5),-(sp)
  4505.     move.l    a3,-(sp)
  4506.     bsr    do_permit
  4507.     lea    (sp),a1
  4508.     lea    inform2(pc),a0
  4509.     bsr    new_print
  4510.     lea    12(sp),sp
  4511.     bra    jajo
  4512.  
  4513. itsDos    move.l    id_VolumeNode(a5),a0    ;DOS-Disk
  4514.     add.l    a0,a0
  4515.     add.l    a0,a0
  4516.     move.l    $28(a0),a0        ;name    (hope, it is NULL-ending)
  4517.     add.l    a0,a0
  4518.     add.l    a0,a0
  4519.     addq.l    #1,a0
  4520.     move.l    a0,-(sp)
  4521.     move.l    id_NumSoftErrors(a5),-(sp)    ;SoftErrors
  4522.     move.l    id_DiskState(a5),d0
  4523.     lea    statro(pc),a0
  4524.     moveq    #80,d1
  4525.     cmp.l    d1,d0
  4526.     beq.s    .H
  4527.     lea    statrw(pc),a0
  4528.     moveq    #82,d1
  4529.     cmp.l    d1,d0
  4530.     beq.s    .H
  4531.     lea    statval(pc),a0
  4532.     moveq    #81,d1
  4533.     cmp.l    d1,d0
  4534.     beq.s    .H
  4535.     lea    statun(pc),a0
  4536. .H    move.l    a0,-(sp)        ;Status
  4537.     move.l    id_BytesPerBlock(a5),d1
  4538.     move.l    d1,-(sp)        ;BlockSize
  4539.     move.l    id_NumBlocks(a5),d0
  4540.     bsr    mult_32x32
  4541.     lsr.l    #8,d0
  4542.     lsr.l    #2,d0
  4543.     move.l    d0,d2
  4544.     move.l    id_NumBlocksUsed(a5),d0
  4545.     bsr    mult_32x32
  4546.     lsr.l    #8,d0
  4547.     lsr.l    #2,d0
  4548.     move.l    d2,d3
  4549.     sub.l    d0,d3
  4550.     moveq    #100,d1
  4551.     bsr    mult_32x32
  4552.     move.l    d2,d1
  4553.     beq.s    .D
  4554.     bsr    div_32    ;%
  4555. .D    exg    d0,d2
  4556.     move.l    d3,d1
  4557.     movem.l    d0-d2,-(sp)        ;Sizes
  4558.     lea    msd_tx(pc),a0    messydos ?
  4559.     move.l    $1c(a4),d0    dn_Startup
  4560.     moveq    #2,d1
  4561.     cmp.l    d1,d0
  4562.     bls.s    .A
  4563.     lsl.l    #2,d0
  4564.     move.l    d0,a1
  4565.     move.l    8(a1),d0    fssm_Environ
  4566.     beq.s    .A
  4567.     lsl.l    #2,d0
  4568.     move.l    d0,a1
  4569.     move.l    64(a1),d0    de_DosType
  4570.     cmp.l    #"MSD"<<8,d0    CrossDos ?
  4571.     beq.s    .C
  4572. .A    move.l    id_DiskType(a5),d0
  4573.     lea    quest_tx(pc),a0
  4574.     cmp.b    #5,d0
  4575.     bhi.s    .C    unknown
  4576.     ext.w    d0
  4577.     ext.l    d0
  4578.     lea    ofs_tx(pc),a0
  4579.     lsl.l    #2,d0
  4580.     add.l    d0,a0    d0*4+a0    access table
  4581. .C    move.l    a0,-(sp)        ;System
  4582.     move.l    id_UnitNumber(a5),-(sp)    ;Unit
  4583.     move.l    a3,-(sp)        ;Name
  4584.     bsr    do_permit
  4585.     lea    (sp),a1
  4586.     lea    inform(pc),a0
  4587.     bsr    new_print
  4588.     lea    40(sp),sp
  4589.     bra    jajo
  4590.  
  4591.  
  4592.  
  4593. *****************
  4594. *    ENDCLI    *    EXIT FROM ZSHELL TO CLI.
  4595. *****************    IF WE EXIT FROM SCRIPT THEN FREE SCRIPT MEMORY
  4596. endcliz    bsr    raw_off
  4597.     move.l    parm2(a5),a0
  4598.     bsr    return_dash_option
  4599.     moveq    #-1,d7
  4600.     cmp.b    #'C',d0
  4601.     bne.s    .A
  4602.     moveq    #0,d7
  4603. .A    tst.b    scflag(a5)
  4604.     beq.s    .B
  4605.     bsr    kill_script
  4606. .B    move.l    (sp)+,d0    ;kill return address on stack
  4607.     rts
  4608.  
  4609. ** CHECK DIRECTORY DESCRIPTION IN (A0) AND CONVERTS INTO DIRNAME[0] AND PUTS
  4610. ** THE WILD CARD IN WILD_STRING. ALSO SETS WILD_FLAG
  4611. handle_wild_dirs
  4612.     clr.b    wild_flag(a5)
  4613.     btst    #FLwild,Flags+3(a5)
  4614.     beq.s    .B
  4615.     cmp.w    #37,kickver(a5)
  4616.     blo.s    .B
  4617.     movem.l    d2-d3/a0,-(sp)
  4618.     lea    tempbuf(a5),a1
  4619.     move.l    a1,d1
  4620.     bsr    rempath
  4621.     lea    NewPrintBuffer(a5),a0
  4622.     move.l    a0,d2
  4623.     moveq    #120,d3
  4624.     jsr    _LVOParsePatternNC(a6)    external matcher
  4625.     movem.l    (sp)+,d2-d3/a0
  4626.     tst.l    d0
  4627.     bmi.s    .A
  4628.     bne.s    .C
  4629. .B    bsr    check_wild    internal matcher
  4630.     tst.b    d0
  4631.     bne.s    .A
  4632. .C    lea    wild_string(a5),a1
  4633.     bsr    split_wild
  4634.     move.b    #1,wild_flag(a5)
  4635. .A    rts    
  4636.  
  4637. ** SPLIT STRING(A0) INTO DIRECTORY PATH AND WILDCARD DESCRIPTION
  4638. ** NULL END THE PATH, AND MOVE THE WILDCARD TO (A1)
  4639. * eg. ram:c/*.info -> ram:c0 + *.info0    
  4640. split_wild
  4641.     movem.l    d0-d1/a0-a2,-(sp)
  4642.     move.l    a0,d1
  4643. sp_w2    move.l    a0,a2    a2=temp
  4644. sp_w3    move.b    (a0)+,d0
  4645.     beq.s    sp_w4
  4646.     cmp.b    #':',d0
  4647.     beq.s    sp_w2    A0= 1 after :
  4648.     cmp.b    #'/',d0
  4649.     beq.s    sp_w2
  4650.     bra.s    sp_w3
  4651. sp_w4    cmp.l    a2,d1
  4652.     beq.s    sp_mis
  4653.     cmp.b    #':',-1(a2)
  4654.     bne.s    sp_w5
  4655. sp_mis    move.l    a2,d1    SAVE POSITION
  4656. sp_w6    move.b    (a2)+,(a1)+
  4657.     bne.s    sp_w6
  4658.     move.l    d1,a2
  4659.     clr.b    (a2)
  4660.     movem.l    (sp)+,d0-d1/a0-a2
  4661.     rts
  4662. sp_w5    clr.b    -1(a2)
  4663. sp_w7    move.b    (a2)+,(a1)+
  4664.     bne.s    sp_w7
  4665.     movem.l    (sp)+,d0-d1/a0-a2
  4666.     rts
  4667.     
  4668. ** CHECK STRING(A0) IF IT CONTAINS WILDCARD SPECIFIC CHARS
  4669. ** RETURN D0=0 IF WILDS FOUND
  4670. check_wild    ;only used by handle_wild_dirs
  4671.     move.l    a0,-(sp)
  4672. chk_w3    move.b    (a0)+,d0
  4673.     beq.s    chk_w2
  4674.     cmp.b    #'*',d0
  4675.     beq.s    chk_w4
  4676.     cmp.b    #'~',d0    special not char
  4677.     beq.s    chk_w4
  4678.     cmp.b    #'[',d0
  4679.     beq.s    chk_w4
  4680.     cmp.b    #']',d0
  4681.     beq.s    chk_w4
  4682.     cmp.b    #'|',d0 or char
  4683.     beq.s    chk_w4
  4684.     cmp.b    #'?',d0
  4685.     bne.s    chk_w3
  4686. chk_w4    moveq    #0,d0
  4687.     move.l    (sp)+,a0
  4688.     rts
  4689. chk_w2    moveq    #1,d0
  4690.     move.l    (sp)+,a0
  4691.     rts
  4692.  
  4693. * NOTE this wildmatcher only handles cases where the wildcard has one * in it.
  4694. ** WILDCARD MATCHER. CHECK IF STRING(A0) MATCHES WILDCARD(A1)
  4695. ** RETURN D0=0 IF MATCH
  4696. wildmatch2
  4697.     btst    #FLwild,Flags+3(a5)
  4698.     beq.s    wildmatch
  4699.     cmp.w    #37,kickver(a5)
  4700.     blo.s    wildmatch
  4701.     movem.l    d2/a0/a1,-(sp)
  4702.     move.l    a0,d2
  4703.     lea    NewPrintBuffer(a5),a0
  4704.     move.l    a0,d1
  4705.     jsr    _LVOMatchPatternNC(a6)    external matcher
  4706.     movem.l    (sp)+,d2/a0/a1
  4707.     moveq    #0,d1
  4708.     tst.l    d0
  4709.     bne.s    .A
  4710.     addq.l    #1,d1
  4711. .A    move.l    d1,d0
  4712.     rts
  4713. wildmatch movem.l    d2/a2-a3,-(sp)
  4714.     move.b    (a1),d2
  4715.     cmp.b    #"~",d2        ;check if all is negated
  4716.     bne.s    .C
  4717.     addq.l    #1,a1
  4718. .C    move.l    a1,a2
  4719.     move.l    a0,a3
  4720. .A    move.b    (a2)+,d0
  4721.     beq.s    .B
  4722.     cmp.b    #"|",d0        ;or-symbol  V2.0
  4723.     bne.s    .A
  4724.     move.b    #0,-1(a2)    ;change wildcard to end
  4725.     bsr.s    wildermatch
  4726.     move.b    #"|",-1(a2)    ;restore
  4727.     tst.l    d0
  4728.     beq.s    gut
  4729.     lea    (a3),a0
  4730.     lea    (a2),a1
  4731.     bra.s    .A
  4732. .B    bsr.s    wildermatch
  4733. gut    cmp.b    #"~",d2
  4734.     bne.s    .D
  4735.     subq.l    #1,d0
  4736. .D    movem.l    (sp)+,d2/a2-a3
  4737.     rts
  4738.  
  4739. wildermatch
  4740.     cmp.b    #'~',(a1)        check for NOT specifier
  4741.     bne.s    wm_1
  4742.     move.b    (a1)+,d0
  4743.     bsr.s    wm_1
  4744.     subq.l    #1,d0    0 --> -1     1 --> 0
  4745.     rts
  4746.     
  4747. wm_1    move.b    (a0)+,d0
  4748.     beq    source_fin1
  4749.     move.b    (a1)+,d1
  4750.     cmp.b    #'*',d1
  4751.     beq.s    wild_run
  4752.     cmp.b    #'[',d1        handle character classes
  4753.     bne.s    .A
  4754. .B    move.b    (a1)+,d1
  4755.     beq.s    wild_fail
  4756.     cmp.b    #']',d1
  4757.     beq.s    wild_fail
  4758.     bsr    compD1D0nocase
  4759.     bne.s    .B
  4760. .C    move.b    (a1)+,d1
  4761.     beq.s    wild_fail
  4762.     cmp.b    #']',d1
  4763.     bne.s    .C
  4764.     bra.s    wm_1
  4765. .A    cmp.b    #'?',d1
  4766.     beq.s    wm_1
  4767.     bsr    compD1D0nocase
  4768.     beq.s    wm_1
  4769.     
  4770. wild_fail    moveq    #1,d0
  4771.     rts
  4772. wild_run    
  4773. wr_3    tst.b    (a0)+    GOTO END OF STRING
  4774.     bne.s    wr_3
  4775. wr_4    tst.b    (a1)+    GOTO END OF WILDCARD
  4776.     bne.s    wr_4
  4777. wr_5    move.b    -(a1),d0    get tail of wildcard (1st should be null)
  4778.     move.b    -(a0),d1
  4779.     cmp.b    #'*',d0
  4780.     beq.s    source_fin2
  4781.     cmp.b    #']',d0        handle class [xyz]
  4782.     bne.s    .A
  4783. .B    move.b    -(a1),d0
  4784.     cmp.b    #'*',d0
  4785.     beq.s    wild_fail
  4786.     cmp.b    #'[',d0
  4787.     beq.s    wild_fail
  4788.     bsr    compD1D0nocase
  4789.     bne.s    .B
  4790. .C    move.b    -(a1),d0
  4791.     beq.s    wild_fail    should never happen but should leave in
  4792.     cmp.b    #'[',d0
  4793.     bne.s    .C
  4794.     bra.s    wr_5
  4795. .A    cmp.b    #'?',d0
  4796.     beq.s    wr_5
  4797.     bsr    compD1D0nocase
  4798.     beq.s    wr_5
  4799.     bra.s    wild_fail
  4800. source_fin1
  4801.     tst.b    (a1)
  4802.     beq.s    source_fin2
  4803.     cmp.b    #'*',(a1)
  4804.     bne.s    wild_fail
  4805. source_fin2
  4806.     moveq    #0,d0
  4807.     rts
  4808.  
  4809. compD1D0nocase    ;lowercase d0 and d1 then compare them
  4810.     cmp.b    #'Z',d1
  4811.     bhi.s    D1_OK
  4812.     cmp.b    #'A',d1
  4813.     blo.s    D1_OK
  4814.     add.b    #$20,d1
  4815. D1_OK    cmp.b    #'Z',d0
  4816.     bhi.s    D0_OK
  4817.     cmp.b    #'A',d0
  4818.     blo.s    D0_OK
  4819.     add.b    #$20,d0
  4820. D0_OK    cmp.b    d1,d0
  4821.     rts
  4822.     
  4823. fibexnx    move.l    d7,d1
  4824.     move.l    a5,d2
  4825.     jsr    _LVOExNext(a6)
  4826.     rts
  4827.  
  4828. *********************************
  4829. *    DIRECTORY LISTER    *
  4830. *********************************
  4831. fname    equ    40    for sorting
  4832.  
  4833. dirz    clr.l    temp2(a5)        WIDE DIR, 2 columns
  4834.     bset.l    #31,temp2(a5)        bit 31=wide flag
  4835.     bra.s    directory
  4836.  
  4837. listz    clr.l    temp2(a5)        NARROW DIR, clear wide flag
  4838.     bset.l    #29,temp2(a5)        bit 29=verbose flag
  4839.     bset.l    #28,temp2(a5)        bit 28=comment flag
  4840. directory        ;V2.0:many things better (sort!)
  4841.     bsr    check_q_r
  4842. directory2
  4843.     lea    parm2(a5),a2
  4844.     bsr    rawh_off
  4845.     move.l    (a2),d1
  4846.     bne.s    .A
  4847.     lea    null(pc),a0
  4848.     move.l    a0,d1
  4849.     bra.s    .B
  4850.  
  4851. .A    move.l    (a2)+,d1    list all parms
  4852.     beq.s    .C
  4853. .B    move.l    a2,-(sp)
  4854.     move.l    d1,a2
  4855.     bsr    DirLister
  4856.     move.l    (sp)+,a2
  4857.     tst.l    d0
  4858.     bne.s    .E
  4859.     tst.b    break_flag(a5)
  4860.     beq.s    .A
  4861. .C    moveq    #RETURN_OK,d0
  4862. .E    rts
  4863.  
  4864. DirLister    ;wants dirname or filename in a2
  4865. *temp2-bits:    31:wide dir: DIR
  4866. *        30:quick, nosort: (all)
  4867. *        29:verbose list: LIST
  4868. *        28:comment: LIST
  4869. *        27:footer: (auto)
  4870. *        26:delete file: DELETE,MOVE
  4871. *        25:not process file: DELETE,COPY,MOVE
  4872. *        24:protect: PROTECT
  4873. *        23:copy: COPY,MOVE
  4874. *        22:move: MOVE
  4875. *        21:rename: MOVE
  4876. *        20:join: JOIN
  4877.     clr.l    temp1(a5)            init total size
  4878.     and.l    #$fff00000,temp2(a5)
  4879.     clr.l    temp3(a5)
  4880.     clr.l    temp4(a5)
  4881.     bset    #21,temp2+1(a5)
  4882.     btst.l    #31,temp2(a5)
  4883.     beq.s    .A
  4884.     bset    #0,temp2+3(a5)
  4885. .A    btst.l    #30,temp2(a5)
  4886.     beq.s    .B
  4887.     bclr    #28,temp2(a5)
  4888. .B    clr.w    indent_count(a5)
  4889.     move.l    a2,a0
  4890.     bsr    handle_wild_dirs
  4891.     lea    tempbuf(a5),a4
  4892. .C    move.b    (a2)+,(a4)+
  4893.     bne.s    .C
  4894.     bsr    pr_dir            -> print the dir
  4895.  
  4896. pr_size    movem.l    d0-d3,-(sp)        end of dirlister
  4897.     move.l    temp2(a5),d0        are we printing wide
  4898.     bpl.s    .B
  4899.     btst.l    #0,d0
  4900.     bne.s    .B
  4901.     bsr    pr_lf            print missing lf
  4902. .B    lea    (sp),a1
  4903.     lea    totsize(pc),a0
  4904.     btst    #27,temp2(a5)
  4905.     beq.s    .A
  4906.     bsr    new_print        print footer
  4907. .A    lea    16(sp),sp
  4908.     moveq    #RETURN_OK,d0
  4909.     rts
  4910.  
  4911. pr_dir    bset    #27,temp2(a5)
  4912.     bclr    #25,temp2(a5)
  4913.     lea    tempbuf(a5),a0
  4914.     bsr    fibexam
  4915.     bsr    fixsoftlink
  4916.     btst    #24,temp2(a5)        protect flag ?
  4917.     bne.s    .D
  4918.     btst    #26,temp2(a5)        delete flag ?
  4919.     beq.s    .B
  4920. .D    tst.b    wild_flag(a5)
  4921.     beq.s    .C
  4922. .B    tst.l    fib_DirEntryType(a5)    check entry OK
  4923.     bpl.s    prd20            print whole Directory
  4924.  
  4925. .C    bsr    check_c
  4926.     bne.s    .F
  4927.     move.l    d7,d1
  4928.     jsr    _LVOUnLock(a6)        unlock file
  4929.     lea    tempbuf(a5),a0
  4930.     lea    temp2buf(a5),a1
  4931.     bsr    split_wild        separate path and filename
  4932.     lea    tempbuf(a5),a0
  4933.     move.l    a0,d1
  4934.     moveq    #ACCESS_READ,d2
  4935.     jsr    _LVOLock(a6)        get a lock on the dir
  4936.     move.l    d0,d7
  4937.     bsr    pr_it            print single file/dir
  4938.     bclr    #27,temp2(a5)        do not print footer
  4939. .F    bsr    unlock            make sure to unlock
  4940.     rts
  4941.  
  4942. prd20    tst.w    indent_count(a5)    was a dir
  4943.     bne.s    .A
  4944.     move.l    d7,d1
  4945.     jsr    _LVOUnLock(a6)
  4946.     lea    tempbuf(a5),a0
  4947.     move.l    a0,d1
  4948.     moveq    #ACCESS_READ,d2
  4949.     jsr    _LVOLock(a6)
  4950.     lea    temp2buf(a5),a0        get full dir name for later
  4951.     clr.b    (a0)
  4952.     tst.l    d0
  4953.     beq    DOSerr
  4954.     bsr    eval_full_path
  4955.     jsr    _LVOUnLock(a6)
  4956.     lea    dirof(pc),a1
  4957.     bsr    pr_string
  4958.     lea    temp2buf(a5),a1
  4959.     bsr    pr_stringlf        print directory's name
  4960.     lea    tempbuf(a5),a0
  4961.     bsr    fibexam
  4962.  
  4963. .A    sub.l    a3,a3    ;clr a3
  4964. prd2
  4965.     bsr    check_c        CTRL-C pressed ?
  4966.     bne    unlk
  4967.     bsr    fibexnx
  4968.     tst.l    d0
  4969.     beq    unlk        ;sort ?
  4970.     bsr    fixsoftlink
  4971.     move.l    temp2(a5),d0
  4972.     btst    #31,d0
  4973.     beq.s    .C
  4974.     move.l    fib_Protection(a5),d0
  4975.     btst    #7,d0
  4976.     bne.s    prd2    hide if hide flag is set in wide dir lister
  4977.     lea    ignoreit(a5),a1        hide ctrl-ignore
  4978.     tst.b    (a1)
  4979.     beq.s    .C
  4980.     lea    fib_FileName(a5),a0
  4981.     bsr    wildmatch        wildcheck
  4982.     tst.b    d0
  4983.     beq.s    prd2
  4984. .C    tst.b    wild_flag(a5)
  4985.     beq.s    dozel
  4986.     tst.b    recurs_flag(a5)
  4987.     beq.s    .A
  4988.     tst.l    fib_DirEntryType(a5)
  4989.     bpl.s    dozel
  4990. .A    lea    fib_FileName(a5),a0
  4991.     lea    wild_string(a5),a1
  4992.     bsr    wildmatch2        wildcheck (can be external)
  4993.     tst.b    d0
  4994.     bne.s    prd2
  4995. dozel    btst.l    #30,temp2(a5)
  4996.     beq.s    collect            not quick
  4997.     btst    #26,temp2(a5)
  4998.     bne.s    collect            delete
  4999.     bsr    zelma
  5000.     bra.s    prd2
  5001.  
  5002. collect moveq    #fname,d0        collect files to sort  V2.0
  5003.     lea    fib_FileName(a5),a0
  5004.     lea    (a0),a2
  5005. .A    addq.l    #1,d0
  5006.     tst.b    (a0)+
  5007.     bne.s    .A
  5008.     lea    fib_Comment(a5),a0
  5009. .B    addq.l    #1,d0
  5010.     tst.b    (a0)+
  5011.     bne.s    .B
  5012.     moveq    #1,d1
  5013.     bsr    iwantmem
  5014.     beq    unlock
  5015.     move.l    d0,a0
  5016.     move.l    a3,(a0)+
  5017.     lea    -4(a0),a3
  5018.     lea    fib_DiskKey(a5),a1    ;store fib in mem
  5019.     move.l    (a1)+,(a0)+
  5020.     move.l    (a1)+,(a0)+
  5021.     lea    fib_Protection(a5),a1
  5022.     moveq    #6,d1
  5023. .C    move.l    (a1)+,(a0)+
  5024.     dbra    d1,.C
  5025. .D    move.b    (a2)+,(a0)+    ;name
  5026.     bne.s    .D
  5027. .E    move.b    (a1)+,(a0)+    ;comment
  5028.     bne.s    .E
  5029.     bra    prd2
  5030.  
  5031. unlk    btst.l    #26,temp2(a5)
  5032.     bne.s    .A        delete
  5033.     btst.l    #30,temp2(a5)
  5034.     bne    unlock        quick
  5035. .A    move.l    a3,d0    
  5036.     beq    unlock        no files
  5037. ;    tst.b    break_flag(a5)
  5038. ;    bne.s    nextfi        CTRL-C pressed
  5039.  
  5040.     movem.l    a4-a6,-(sp)
  5041.     btst.l    #30,temp2(a5)
  5042.     bne.s    snull        quick
  5043.     lea    (a3),a0        ;INSERTION SORT  V2.0   (ooohuuooo)
  5044. aussort    lea    (a3),a1
  5045.     move.l    (a0),a2    ;remove (a0->) a2
  5046.     move.l    a2,d0
  5047.     beq.s    snull    ;end of list
  5048.     move.l    (a2),(a0)
  5049.     bsr    strcmp    ;compare a1 and a2
  5050.     bne.s    insort    ;insert a2 (old place)
  5051.     move.l    a2,a3    ;a2->start
  5052.     move.l    a1,(a2)    ;a1=old start
  5053.     bra.s    aussort    ;next
  5054. insort    move.l    a1,a4    ;reminder
  5055.     move.l    (a1),a1    ;next a1
  5056.     cmp.l    a0,a4
  5057.     beq.s    inold
  5058. shno    bsr    strcmp    ;compare a1 and a2
  5059.     bne.s    insort    ;go on
  5060.     move.l    a2,(a4)    ;insert a2
  5061.     move.l    a1,(a2)    ;a4->a2->a1
  5062.     bra.s    aussort
  5063. inold    move.l    (a0),(a2) ;a2 back at old place
  5064.     move.l    a2,(a0)    ;a0->a2->next
  5065.     move.l    a2,a0    ;next a0
  5066.     bra.s    aussort
  5067. snull    movem.l    (sp)+,a4-a6    ;FINISHED !!!
  5068.  
  5069.     tst.l    temp2(a5)    for normal DIR
  5070.     bpl.s    nextfi
  5071.     tst.b    recurs_flag(a5)
  5072.     bne.s    nextfi
  5073.     moveq    #1,d0        prepare for printing in 2 columns
  5074.     move.l    a3,d1
  5075. .A    addq.l    #1,d0
  5076.     move.l    d1,a0
  5077.     move.l    (a0),d1
  5078.     bne.s    .A        count number of entries (d0)
  5079.     lsr.l    #1,d0        divide by two
  5080.     move.l    a3,a2
  5081.     bra.s    .B
  5082. .C    move.l    a2,a0
  5083.     move.l    (a2),a2
  5084. .B    dbra    d0,.C        find the middle    (a2 ,precedor in a0)
  5085.     clr.l    (a0)
  5086.  
  5087. nextfi    lea    4(a3),a1    print all files
  5088.     lea    fib_DiskKey(a5),a0    ;restore fib from mem
  5089.     move.l    (a1)+,(a0)+
  5090.     move.l    (a1)+,(a0)+
  5091.     lea    fib_Protection(a5),a0
  5092.     moveq    #6,d1
  5093. .F    move.l    (a1)+,(a0)+
  5094.     dbra    d1,.F
  5095.     moveq    #fname,d0
  5096.     lea    fib_FileName(a5),a0
  5097. .H    addq.l    #1,d0
  5098.     move.b    (a1)+,(a0)+    ;name
  5099.     bne.s    .H
  5100.     lea    fib_Comment(a5),a0
  5101. .B    addq.l    #1,d0
  5102.     move.b    (a1)+,(a0)+    ;comment
  5103.     bne.s    .B
  5104.     movem.l    d0/a2/a3,-(sp)
  5105.     tst.b    break_flag(a5)
  5106.     bne.s    .C        CTRL-C pressed
  5107.     bsr    check_c
  5108.     bne.s    .C
  5109.     bsr    zelma
  5110. .C    movem.l    (sp)+,d0/a2/a3
  5111.     move.l    (a3),d2
  5112.     lea    (a3),a1
  5113.     bsr    givemem
  5114.     move.l    d2,a3
  5115.     tst.l    temp2(a5)
  5116.     bpl.s    .A
  5117.     tst.b    recurs_flag(a5)
  5118.     bne.s    .A
  5119.     move.l    a2,a0        swap lower and upper list
  5120.     move.l    a3,a2
  5121.     move.l    a0,a3
  5122. .A    move.l    a3,d0        tst.l    a3
  5123.     bne    nextfi
  5124.  
  5125. unlock    move.l    d7,d1
  5126.     jsr    _LVOUnLock(a6)
  5127.     move.l    temp1(a5),d0    ;total size
  5128.     move.l    temp4(a5),d1
  5129.     move.l    temp2(a5),d2    ;No. of files and dirs
  5130.     btst.l    #31,d2
  5131.     beq.s    .A
  5132.     subq.l    #1,d2
  5133. .A    and.l    #$000fffff,d2    ;1.000.000 files max. should be enough
  5134.     move.l    temp3(a5),d3    ;No. of dirs
  5135.     sub.l    d3,d2
  5136.     rts
  5137.  
  5138. strcmp    move.l    8(a1),d0
  5139.     move.l    8(a2),d1
  5140.     bmi.s    .A
  5141.     tst.l    d0    a2 is dir
  5142.     bpl.s    .B    a1 is dir too
  5143.     bra.s    donoth    a2:dir    a1:file
  5144. .A    tst.l    d0    a2 is file
  5145.     bpl.s    inseit    a2:file    a1:dir
  5146. .B    lea    fname(a1),a5    a1 is file too
  5147.     lea    fname(a2),a6
  5148. stcmp    move.b    (a5)+,d1    ;compare strings in a3 and a4
  5149.     beq.s    donoth
  5150.     move.b    (a6)+,d0
  5151.     beq.s    inseit
  5152.     bsr    compD1D0nocase
  5153.     beq.s    stcmp
  5154.     bhi.s    donoth
  5155. inseit    moveq    #0,d0        ;insert it !
  5156.     rts
  5157. donoth    moveq    #1,d0        ;do nothing !
  5158.     rts
  5159.  
  5160.  
  5161. zelma    tst.l    fib_DirEntryType(a5)
  5162.     bpl.s    .C
  5163.     bsr    pr_it        print file
  5164.     rts
  5165. .C    tst.b    recurs_flag(a5)
  5166.     bne.s    .B
  5167.     bsr    pr_it        print dir
  5168. .A    rts
  5169. .B    bset    #25,temp2(a5)    do not process this dir
  5170.     bsr    pr_it        print dir recursive
  5171.     bclr    #25,temp2(a5)
  5172.     move.w    temp2(a5),d0
  5173.     and.w    #%0000010010010000,d0    copy,delete or join flag
  5174.     beq.s    .D        no
  5175.     btst    #23,temp2+1(a5)    copy ?
  5176.     beq.s    .E
  5177.     move.l    temp5(a5),d1    yes:create new dir
  5178.     bsr    CurrentDir
  5179.     move.l    d0,d3
  5180.     lea    fib_FileName(a5),a2    copy: create dir
  5181.     move.l    a2,d1
  5182.     jsr    _LVOCreateDir(a6)
  5183.     move.l    d0,d2
  5184.     bne.s    .F
  5185. .G    move.l    d3,d1
  5186.     bsr    CurrentDir
  5187.     jsr    _LVOIoErr(a6)
  5188.     move.l    d0,d2
  5189.     bsr    pr_lf
  5190.     move.l    d2,d0
  5191.     bsr    pr_DOSerr
  5192.     rts
  5193. .F    move.l    d2,d1        unlock new dir, because is exclusive
  5194.     jsr    _LVOUnLock(a6)
  5195.     move.l    a2,d1
  5196.     moveq    #ACCESS_READ,d2
  5197.     jsr    _LVOLock(a6)
  5198.     move.l    d0,d2
  5199.     beq.s    .G
  5200.     move.l    d3,d1
  5201.     bsr    CurrentDir
  5202.     move.l    temp5(a5),d1    unlock old in temp5
  5203.     jsr    _LVOUnLock(a6)
  5204.     move.l    d2,temp5(a5)
  5205.     lea    makedirOK(pc),a1
  5206.     bsr    pr_string
  5207.     bsr    AdjustPath
  5208.     bra.s    .D
  5209. .E    bsr    pr_lf        no copy: just print lf
  5210.  
  5211. .D    moveq    #120,d0    ;(24bytes per recurs + subs + move-path)
  5212.     bsr    stacktest
  5213.     bne    .A
  5214.     move.l    fib_DiskKey(a5),d0
  5215.     movem.l    d0/d7/a4,-(sp)
  5216.     lea    fib_FileName(a5),a0
  5217.     lea    -1(a4),a4
  5218.     lea    tempbuf(a5),a1
  5219.     cmp.l    a1,a4
  5220.     beq.s    jo
  5221.     cmp.b    #":",-1(a4)
  5222.     beq.s    jo
  5223.     move.b    #"/",(a4)
  5224.     lea    1(a4),a4
  5225. jo    move.b    (a0)+,(a4)+        ;addpath
  5226.     bne.s    jo
  5227.     addq.w    #2,indent_count(a5)
  5228. jojo    bsr    pr_dir            RECURSION    V2.0
  5229.     subq.w    #2,indent_count(a5)
  5230.     movem.l    (sp)+,d0/d7/a4
  5231.     move.l    d0,fib_DiskKey(a5)    ;restore fib
  5232.     lea    -1(a4),a0
  5233.     cmp.b    #"/",(a0)
  5234.     bne.s    .D
  5235.     clr.b    (a0)
  5236.     lea    1(a0),a0
  5237. .D    lea    (a0),a2
  5238.     lea    fib_FileName(a5),a1
  5239. je    move.b    (a0)+,(a1)+
  5240.     bne.s    je
  5241.     clr.b    (a2)
  5242.     moveq    #2,d0
  5243.     move.l    d0,fib_DirEntryType(a5)
  5244.     move.l    d0,fib_EntryType(a5)
  5245.     moveq    #0,d0
  5246.     move.l    d0,fib_Size(a5)
  5247.     move.l    d0,fib_NumBlocks(a5)
  5248.     btst    #23,temp2+1(a5)    copy ?
  5249.     beq.s    .B
  5250.     move.l    temp5(a5),d2    COPY
  5251.     move.l    d2,d1
  5252.     jsr    _LVOParentDir(a6)
  5253.     move.l    d0,temp5(a5)
  5254.     move.l    d2,d1
  5255.     jsr    _LVOUnLock(a6)
  5256.     bsr    AdjustPath
  5257. .B    btst    #26,temp2(a5)    delete ?
  5258.     beq.s    .A
  5259.     move.l    temp2(a5),-(sp)
  5260.     bclr    #22,temp2+1(a5)    move off
  5261.     bsr    pr_it        now delete this dir
  5262.     move.l    (sp)+,temp2(a5)
  5263. .A    rts
  5264.  
  5265. AdjustPath
  5266.     btst    #22,temp2+1(a5)
  5267.     beq.s    .D
  5268.     btst    #21,temp2+1(a5)
  5269.     beq.s    .D
  5270.     move.l    temp5(a5),d1
  5271.     jsr    _LVODupLock(a6)
  5272.     tst.l    d0
  5273.     beq    DOSerr
  5274.     move.l    temp7(a5),a0
  5275.     bsr    eval_full_path
  5276.     jsr    _LVOUnLock(a6)
  5277. .D    rts
  5278.  
  5279. pr_it    bsr    num_spc            print file or dir
  5280.     tst.l    fib_DirEntryType(a5)    check whether is dir
  5281.     bmi.s    .A            if plus,is directory
  5282.     move.l    temp2(a5),d0        check for "DIR -R"
  5283.     bpl.s    .G
  5284.     tst.b    recurs_flag(a5)
  5285.     beq.s    .G
  5286.     btst    #0,d0
  5287.     bne.s    .H
  5288.     subq.l    #1,temp2(a5)
  5289.     bsr    pr_lf            for DIR -R directories
  5290. .H    addq.l    #1,temp2(a5)
  5291. .G    lea    farb3(pc),a1        change foregnd colour
  5292.     bsr    addstring
  5293.     addq.l    #1,temp3(a5)        one dir more
  5294. .A    lea    fib_FileName(a5),a1
  5295.     move.l    a1,a0
  5296.     moveq    #-1,d2
  5297.     add.w    indent_count(a5),d2
  5298. .B    addq    #1,d2
  5299.     tst.b    (a0)+
  5300.     bne.s    .B
  5301.     bsr     addstring        print filename
  5302.  
  5303.     tst.l    fib_DirEntryType(a5)
  5304.     bpl.s    .C
  5305. .F    move.l    fib_NumBlocks(a5),d0
  5306.     add.l    d0,temp4(a5)
  5307.     move.l    fib_Size(a5),d0
  5308.     add.l    d0,temp1(a5)        increase total size
  5309.     move.b    #" ",(a2)+
  5310.     moveq    #34,d1
  5311.     sub.w    d2,d1
  5312.     bsr    qdecpr
  5313.     bra.s    prlink
  5314. .C    moveq    #29,d1
  5315.     sub.w    d2,d1
  5316.     bpl.s    .D
  5317.     moveq    #0,d1
  5318. .D    move.b    #" ",(a2)+
  5319.     dbra    d1,.D
  5320.     lea    dirtext(pc),a1
  5321.     bsr    addstring
  5322. prlink    move.b    #" ",(a2)+
  5323.     move.b    #" ",(a2)+
  5324.     move.l    fib_DirEntryType(a5),d0
  5325.     moveq    #-6,d1
  5326.     cmp.l    d1,d0
  5327.     bne.s    .B
  5328.     move.b    #"S",-1(a2)
  5329.     bra.s    .A
  5330. .B    moveq    #4,d1
  5331.     cmp.l    d1,d0
  5332.     bne.s    .C
  5333.     move.b    #"H",-1(a2)
  5334.     bra.s    .A
  5335. .C    moveq    #-4,d1
  5336.     cmp.l    d1,d0
  5337.     bne.s    .A
  5338.     move.b    #"H",-1(a2)
  5339. .A    move.b    #" ",(a2)+
  5340.     addq.l    #1,temp2(a5)
  5341.     move.l    temp2(a5),d0        are we printing wide
  5342.     bpl.s    wpro
  5343.     btst.l    #0,d0
  5344.     beq.s    .F
  5345.     move.b    #LF,(a2)+
  5346. .F    clr.b    (a2)
  5347.     lea    temp2buf(a5),a1
  5348.     bra    pr_string        print string&return and return
  5349.  
  5350. wpro    btst    #29,temp2(a5)
  5351.     beq.s    .E
  5352.     move.l    a2,a0
  5353.     bsr    pr_pro2            print protection V2.0
  5354.     move.b    #" ",(a0)+
  5355.     move.l    a0,a2            (goes to temp2buf)
  5356.     btst    #24,temp2(a5)        protect flag ?
  5357.     bne.s    .E
  5358.     lea    fib_Date(a5),a1
  5359.     lea    -14(sp),sp
  5360.     lea    (sp),a0
  5361.     bsr    convert_time
  5362.     move.l    a2,a1
  5363.     bsr    qprint10
  5364.     move.b    #".",(a1)+
  5365.     bsr    qprint10
  5366.     move.b    #".",(a1)+
  5367.     bsr    qprint10
  5368.     move.b    #" ",(a1)+
  5369.     move.b    #" ",(a1)+
  5370.     bsr    qprint10
  5371.     move.b    #":",(a1)+
  5372.     bsr    qprint10
  5373.     move.b    #":",(a1)+
  5374.     bsr    qprint10
  5375.     move.b    #LF,(a1)+
  5376.     lea    14(sp),sp
  5377.     move.l    a1,a2
  5378. .E    clr.b    (a2)
  5379.     lea    temp2buf(a5),a1
  5380.     bsr    pr_string        print date/time V2.0
  5381.  
  5382.     move.l    d7,d1
  5383.     bsr    CurrentDir        d0=old current dir
  5384.     movem.l    d0/d4-d7/a3-a4,-(sp)
  5385.     move.l    d7,d6
  5386.     btst.l    #28,temp2(a5)
  5387.     beq    fort
  5388.     tst.b    fib_Comment(a5)
  5389.     beq.s    .A
  5390.     bsr    num_spc
  5391.     lea    farb2(pc),a1
  5392.     bsr    addstring
  5393.     move.b    #":",(a2)+
  5394.     clr.b    (a2)
  5395.     lea    temp2buf(a5),a1
  5396.     bsr    pr_string
  5397.     lea    fib_Comment(a5),a1
  5398.     bsr    pr_string        print Comment V2.0
  5399.     lea    farb1(pc),a1
  5400.     bsr    pr_stringlf
  5401.  
  5402. .A    cmp.w    #36,kickver(a5)
  5403.     blo    fort
  5404.     move.l    fib_DirEntryType(a5),d0
  5405.     bpl.s    .F
  5406.     neg.l    d0
  5407. .F    moveq    #4,d1
  5408.     cmp.l    d0,d1
  5409.     bne.s    .G
  5410.     lea    NewPrintBuffer(a5),a2    process hardlinks
  5411.     lea    farb2(pc),a1
  5412.     bsr    addstring
  5413.     lea    pfeil(pc),a1
  5414.     bsr    addstring
  5415.     lea    fib_FileName(a5),a0
  5416.     move.l    a0,d1
  5417.     moveq    #ACCESS_READ,d2
  5418.     jsr    _LVOLock(a6)
  5419.     tst.l    d0
  5420.     beq.s    .C
  5421.     move.l    a2,a0
  5422.     bsr    eval_full_path
  5423.     jsr    _LVOUnLock(a6)
  5424.     bra.s    .B
  5425. .G    moveq    #-6,d0
  5426.     cmp.l    fib_DirEntryType(a5),d0    check whether is softlink
  5427.     bne.s    fort
  5428.     lea    fib_FileName(a5),a2    process softlinks
  5429.     move.l    a2,d1
  5430.     jsr    _LVODeviceProc(a6)
  5431.     move.l    d0,d4
  5432.     beq.s    .C
  5433.     move.l    a2,d3    path (filename)
  5434.     lea    NewPrintBuffer(a5),a2
  5435.     lea    farb2(pc),a1
  5436.     bsr    addstring
  5437.     lea    pfeil(pc),a1
  5438.     bsr    addstring
  5439.     move.l    d4,d1    msgport of device
  5440.     move.l    d6,d2    lock on current dir
  5441.     move.l    a2,d4    buffer
  5442.     moveq    #120,d5    size of buffer
  5443.     jsr    _LVOReadLink(a6)
  5444. .C    bsr    maybeDOSerr
  5445.     beq.s    fort
  5446. .B    lea    NewPrintBuffer(a5),a1
  5447.     bsr    pr_string        ;print softlink V2.3
  5448.     lea    farb1(pc),a1
  5449.     bsr    pr_stringlf
  5450.  
  5451. fort    move.w    temp2(a5),d0    get upper two bytes
  5452.     and.w    #%0000010010010000,d0    copy,delete or join flag
  5453.     beq    .B        no: try protect
  5454.     btst    #25,temp2(a5)
  5455.     bne    .A        not process flag ?
  5456.  
  5457.     btst    #22,temp2+1(a5)        move flag ?
  5458.     beq.s    .E
  5459.     btst    #21,temp2+1(a5)        MOVE !
  5460.     beq.s    .E    need not try to rename
  5461.     tst.l    fib_DirEntryType(a5)
  5462.     bpl.s    .D    delete dir
  5463.     lea    fib_FileName(a5),a0
  5464.     bsr    MoveFile
  5465.     bne    .A
  5466.     bclr    #21,temp2+1(a5)    cannot rename
  5467.  
  5468. .E    btst    #23,temp2+1(a5)        copy flag ?
  5469.     beq.s    .D
  5470.     tst.l    fib_DirEntryType(a5)
  5471.     bpl    .H
  5472.     lea    fib_FileName(a5),a0    COPY !
  5473.     bsr    CopyFileToDir
  5474.     bne    .A        error occured->not delete
  5475.  
  5476. .D    btst    #26,temp2(a5)        delete flag ?
  5477.     beq.s    .C
  5478.     lea    fib_FileName(a5),a0    DELETE !
  5479.     tst.l    fib_DirEntryType(a5)
  5480.     bpl.s    .I    
  5481.     bsr    DoDelete
  5482.     bra.s    .C
  5483. .I    bsr    DoDelete2
  5484.  
  5485. .C    btst    #20,temp2+1(a5)        join flag ?
  5486.     beq.s    .B
  5487.     tst.l    fib_DirEntryType(a5)
  5488.     bpl.s    .H
  5489.     lea    fib_FileName(a5),a0    JOIN !
  5490.     bsr    JoinFile
  5491.  
  5492. .B    btst    #24,temp2(a5)        protect flag ?
  5493.     beq.s    .A
  5494.     move.l    fib_Protection(a5),d2    PROTECT !
  5495.     eor.b    #$0f,d2
  5496.     or.l    temp5(a5),d2
  5497.     and.l    temp6(a5),d2
  5498.     lea    fib_FileName(a5),a0
  5499.     move.l    a0,d1
  5500.     eor.b    #$0f,d2
  5501.     move.l    d2,fib_Protection(a5)
  5502.     jsr    _LVOSetProtection(a6)
  5503.     bsr    maybeDOSerr
  5504.     lea    temp2buf(a5),a2    print new protection
  5505.     lea    pfeil(pc),a1
  5506.     bsr    addstring
  5507.     move.l    a2,a0
  5508.     bsr    pr_pro2
  5509.     move.b    #LF,(a0)+
  5510.     clr.b    (a0)
  5511.     bsr    pr_string    (temp2buf in a1)
  5512.  
  5513.     bra.s    .A
  5514. .H    bsr    pr_lf
  5515. .A    movem.l    (sp)+,d0/d4-d7/a3-a4
  5516.     move.l    d0,d1
  5517.     bsr    CurrentDir
  5518.     rts
  5519.  
  5520. qprint10 move.w    (a0)+,d0    V2.0
  5521. qpr10    ext.l    d0    (also used by more)
  5522.     divu    #10,d0    Value in d0 , Buffer in a1
  5523.     add.b    #"0",d0
  5524.     move.b    d0,(a1)+
  5525.     swap    d0
  5526.     add.b    #"0",d0
  5527.     move.b    d0,(a1)+
  5528.     rts
  5529.  
  5530. num_spc    lea    temp2buf(a5),a2        V2.0
  5531.     move.w    indent_count(a5),d0
  5532.     moveq    #$3f,d1
  5533.     and.l    d1,d0
  5534.     bra.s    .B
  5535. .A    move.b    #" ",(a2)+    the preceding spaces
  5536. .B    dbra    d0,.A
  5537.     rts
  5538.  
  5539. addstring move.b (a1)+,(a2)+
  5540.     bne.s    addstring
  5541.     subq.l    #1,a2
  5542.     rts
  5543.  
  5544. qdecpr    * Number in d0.l , Length in d1.w , adds string to buffer in a2
  5545.     movem.l    d2/d3/a0,-(sp)    ;Prints Decimal Number in (a2)
  5546.     lea    -12(sp),sp
  5547.     move.l    sp,a0
  5548.     move.l    d1,d3
  5549.     moveq    #0,d2
  5550. .A    moveq    #LF,d1
  5551.     bsr    div_32
  5552.     add.b    #$30,d1
  5553.     move.b    d1,(a0)+
  5554.     addq.w    #1,d2
  5555.     tst.l    d0
  5556.     bne.s    .A
  5557.     sub.w    d2,d3
  5558.     subq.w    #1,d3
  5559.     bmi.s    .B
  5560. .D    move.b    #" ",(a2)+
  5561.     dbra    d3,.D
  5562. .B    subq.w    #1,d2
  5563. .C    move.b    -(a0),(a2)+
  5564.     dbra    d2,.C
  5565.     lea    12(sp),sp
  5566.     movem.l    (sp)+,d2/d3/a0
  5567.     rts
  5568.  
  5569. fixsoftlink
  5570.     moveq    #3,d0
  5571.     cmp.l    fib_DirEntryType(a5),d0        is it a softlink ?
  5572.     bne.s    .A
  5573.     move.l    #-6,fib_DirEntryType(a5)    make it look like a file
  5574. .A    rts
  5575.  
  5576. *** CHECK CTRL_C
  5577. ** RETURN NE if ctrl c, EQ if not
  5578. check_c    movem.l    d0-d1/a0-a1/a6,-(sp)    checks if CTRL-C pressed
  5579.     tst.b    break_flag(a5)
  5580.     bne.s    .A
  5581.     moveq    #0,d0
  5582.     moveq    #0,d1
  5583.     move.l    4.w,a6
  5584.     bset    #SIGBREAKB_CTRL_C,d1
  5585.     jsr    _LVOSetSignal(a6)
  5586.     btst    #SIGBREAKB_CTRL_C,d0
  5587.     beq.s    .B
  5588. .A    move.l    dosbase(a5),a6
  5589.     move.l    #304,d0
  5590.     bsr    pr_DOSerr
  5591.     move.b    #1,break_flag(a5)    NE: STOP!!!
  5592.     movem.l    (sp)+,d0-d1/a0-a1/a6
  5593.     rts
  5594. .B    clr.b    break_flag(a5)
  5595.     moveq    #0,d0            EQ: no stop
  5596.     movem.l    (sp)+,d0-d1/a0-a1/a6
  5597.     rts
  5598.  
  5599.  
  5600. *ALLOCATE MEMORY D0=size D1=type
  5601. iwantmem    movem.l d1/a0-a1,-(sp)
  5602.     move.l 4.w,a6
  5603.     jsr _LVOAllocMem(a6)
  5604.     move.l dosbase(a5),a6
  5605.     movem.l (sp)+,d1/a0-a1
  5606.     tst.l    d0
  5607.     rts
  5608. *FREEMEM A1=ptr to mem block D0=size
  5609. givemem    move.l    4.w,a6
  5610.     jsr    _LVOFreeMem(a6)
  5611.     move.l    dosbase(a5),a6
  5612.     rts
  5613.     
  5614.  
  5615. *REMOVE PATH A0-> source A1->destination
  5616. rempath    movem.l d0/a0-a2,-(sp)
  5617. rempath1    move.l a0,a2
  5618. rempath2    move.b (a0)+,d0
  5619.     cmp.b #'/',d0
  5620.     beq.s rempath1
  5621.     cmp.b #':',d0
  5622.     beq.s rempath1
  5623.     tst.b d0
  5624.     bne.s rempath2
  5625.     move.l a2,a0
  5626.     bsr cp_string
  5627.     movem.l (sp)+,d0/a0-a2
  5628.     rts
  5629.  
  5630.  
  5631. ** PRINT STRING (A1) USING indent_count(a5) AS A SPACE INDENT COUNT
  5632. prindent    movem.l    d7/a0-a1,-(sp)
  5633.     move.w    indent_count(a5),d7
  5634.     move.l    a1,a0
  5635.     and.w    #$3f,d7
  5636.     beq.s    .A
  5637.     bra.s    .B
  5638. .C    bsr    pr_space    print d7 spaces
  5639. .B    dbra    d7,.C
  5640.     move.l    a0,a1
  5641. .A    bsr    pr_string
  5642.     movem.l    (sp)+,d7/a0-a1
  5643.     rts
  5644.  
  5645. ** ENTRY A0 pts to parameter.
  5646. ** EXIT D0=lower case char after dash OR 0 if no dash command.
  5647. return_dash_option
  5648.     moveq    #0,d0
  5649.     cmp.b    #'-',(a0)
  5650.     bne.s    .B
  5651. .A    move.b    1(a0),d0
  5652.     cmp.b    #'a',d0
  5653.     blo.s    .B
  5654.     cmp.b    #'z',d0
  5655.     bhi.s    .B
  5656.     sub.b    #$20,d0
  5657. .B    rts
  5658.  
  5659. check_q_r    ;checks for -q, -s or -r (or ALL) options, parm-ptr in a2
  5660.     lea    parm2(a5),a2
  5661.     clr.b    recurs_flag(a5)
  5662.     btst    #FLall,Flags+3(a5)
  5663.     beq.s    .A
  5664.     lea    alltx(pc),a0
  5665.     bsr    LookForOpt
  5666.     bne.s    .A
  5667.     move.b    #1,recurs_flag(a5)
  5668. .A    move.l    a2,a1
  5669.     move.l    (a1),d0
  5670.     beq.s    .E
  5671.     move.l    d0,a0
  5672.     bsr    return_dash_option
  5673.     tst.l    d0
  5674.     beq.s    .E
  5675.     cmp.b    #"R",d0
  5676.     bne.s    .B
  5677.     move.b    #1,recurs_flag(a5)    -r -> recursive
  5678.     bra.s    .G
  5679. .B    cmp.b    #"Q",d0
  5680.     bne.s    .C
  5681.     bset    #30,temp2(a5)        -q -> quick,nosort
  5682.     bra.s    .G
  5683. .C    cmp.b    #"S",d0
  5684.     bne.s    .E
  5685.     bclr    #30,temp2(a5)        -s -> noquick,sort
  5686. .G    lea    4(a1),a0
  5687. .F    move.l    (a0)+,(a1)+
  5688.     bne.s    .F
  5689.     bra.s    .A
  5690. .E    rts
  5691.  
  5692.  
  5693. CurrentDir    ;same as _LVOCurrentDir(a6)
  5694.     move.l    thistask(a5),a0
  5695.     lea    pr_CurrentDir(a0),a0
  5696.     move.l    (a0),d0
  5697.     move.l    d1,(a0)
  5698.     rts
  5699.  
  5700. *************************
  5701. *    DELETE        *    V2.3 new written
  5702. *************************
  5703. deletez    clr.l    temp2(a5)
  5704.     bset    #26,temp2(a5)
  5705.     bsr    check_q_r
  5706.     move.l    (a2),d0
  5707.     beq    too_less_args
  5708.     move.l    d0,a0
  5709.     lea    devicetx(pc),a1
  5710.     bsr    CheckOpt
  5711.     beq    deldevice    format device quick
  5712.     lea    forcetx(pc),a0
  5713.     bsr    LookForOpt    FORCE-flag ?
  5714.     subq.l    #1,d0
  5715.     move.l    d0,temp5(a5)
  5716.     bra    directory2    delete as many files as given
  5717.  
  5718. DoDelete    ;file to delete in a0
  5719.     btst.l    #30,temp2(a5)
  5720.     bne.s    DoDelete2
  5721.     btst.l    #22,temp2+1(a5)    move-> do not ask
  5722.     bne.s    DoDelete2
  5723.     move.l    a0,-(sp)    ASK first
  5724.     move.l    stdin(a5),d1
  5725.     beq.s    DoDelete2
  5726.     lea    yesnotx(pc),a1
  5727.     bsr    pr_string
  5728.     bsr    raw_on
  5729.     lea    temp2buf(a5),a2
  5730.     clr.b    (a2)
  5731.     move.l    a2,d2
  5732.     moveq    #20,d3    read only 1 char
  5733.     jsr    _LVORead(a6)
  5734.     clr.b    1(a2)
  5735.     move.l    a2,a1
  5736.     bsr    pr_string    show it
  5737.     bsr    pr_space
  5738.     bsr    rawh_off
  5739.     move.l    (sp)+,a0
  5740.     or.b    #$20,(a2)
  5741.     cmp.b    #"y",(a2)    yes ?
  5742.     beq.s    DoDelete2
  5743.     cmp.b    #"a",(a2)    all ?
  5744.     bne.s    .A
  5745.     bset    #30,temp2(a5)    set quick flag
  5746.     bra.s    DoDelete2
  5747. .A    cmp.b    #"q",(a2)    quit ?
  5748.     bne.s    .E
  5749.     move.b    #1,break_flag(a5)
  5750. .E    bsr    pr_lf
  5751.     bra.s    DoDeEnd
  5752. DoDelete2
  5753.     move.l    a0,a2
  5754. .E    move.l    a2,d1
  5755.     jsr    _LVODeleteFile(a6)    delete file/dir
  5756.     tst.l    d0
  5757.     bne.s    .B
  5758. .D    jsr    _LVOIoErr(a6)
  5759.     cmp.l    #222,d0        delete-protected ?
  5760.     bne.s    .A
  5761.     tst.l    temp5(a5)    FORCE-flag ?
  5762.     beq.s    .A
  5763.     move.l    a2,d1
  5764.     moveq    #0,d2
  5765.     jsr    _LVOSetProtection(a6)
  5766.     tst.l    d0
  5767.     beq.s    .D
  5768.     bra.s    .E        try again
  5769. .A    btst.l    #22,temp2+1(a5)
  5770.     bne.s    .F        move: do not print lf
  5771.     bsr    pr_lf            error occured
  5772. .F    bsr    pr_DOSerr
  5773.     bra.s    DoDeEnd
  5774. .B    lea    deleteOK(pc),a1    delete successful
  5775.     btst.l    #22,temp2+1(a5)
  5776.     bne.s    DoDeEnd        move: do not print
  5777.     bsr    pr_string
  5778. DoDeEnd    rts
  5779.  
  5780. *************************
  5781. deldevice        ;formats device quick    V2.3
  5782.     bsr    CheckKS
  5783.     move.l    parm3(a5),d1
  5784.     beq    too_less_args
  5785.     move.l    d1,a2
  5786.     moveq    #-2,d2
  5787.     jsr    _LVOLock(a6)    lock on drive
  5788.     move.l    d0,d7
  5789.     beq    DOSerr
  5790.     move.l    d0,d1
  5791.     move.l    a5,d2        get info data into fib
  5792.     jsr    _LVOInfo(a6)
  5793.     tst.l    d0
  5794.     beq    DOSerrUL
  5795.     move.l    d7,d1
  5796.     jsr    _LVOUnLock(a6)
  5797.     lea    formatask(pc),a1
  5798.     bsr    pr_string
  5799.     bsr    rask
  5800.     tst.l    d0
  5801.     beq.s    .A
  5802.     move.l    parm4(a5),d4
  5803.     bne.s    .B
  5804.     move.l    id_VolumeNode(a5),a0
  5805.     add.l    a0,a0
  5806.     add.l    a0,a0
  5807.     move.l    $28(a0),a1    volumename
  5808.     add.l    a1,a1
  5809.     add.l    a1,a1
  5810.     lea    temp2buf(a5),a4
  5811.     move.l    a4,d4
  5812.     bsr    copy_bstr
  5813.     clr.b    (a4)
  5814. .B    move.l    parm5(a5),d0    check for filesystem
  5815.     beq.s    .D
  5816.     lea    ofs_tx(pc),a1
  5817.     move.l    d0,a0
  5818.     moveq    #0,d3
  5819. .E    bsr    CheckOpt
  5820.     bne.s    .F
  5821.     add.l    #"DOS"<<8,d3
  5822.     bra.s    .G
  5823. .F    addq.b    #1,d3
  5824.     cmp.b    #6,d3
  5825.     bne.s    .E
  5826. .D    move.l    id_DiskType(a5),d3    dostype
  5827. .G    move.l    a2,d1
  5828.     moveq    #-1,d2
  5829.     jsr    _LVOInhibit(a6)        disable drive
  5830.     tst.l    d0
  5831.     beq    DOSerr
  5832.     move.l    a2,d1
  5833.     move.l    d4,d2
  5834.     jsr    _LVOFormat(a6)        format it quick !
  5835.     bsr    maybeDOSerr
  5836.     move.l    a2,d1
  5837.     moveq    #0,d2
  5838.     jsr    _LVOInhibit(a6)        enable drive
  5839.     tst.l    d0
  5840.     beq    DOSerr
  5841. .A    moveq    #RETURN_OK,d0
  5842.     rts
  5843.  
  5844. *************************
  5845. *    PROTECT        *    V2.3 new written
  5846. *************************
  5847. protectz
  5848.     clr.l    temp2(a5)
  5849.     bset    #29,temp2(a5)    bit 29=verbose flag
  5850.     bset    #24,temp2(a5)    bit 24=protect flag
  5851.     bset    #30,temp2(a5)    bit 30=quick flag
  5852.     bsr    check_q_r
  5853.     tst.l    (a2)+
  5854.     beq    too_less_args
  5855.     clr.l    temp5(a5)
  5856.     clr.l    temp6(a5)
  5857. .A    move.l    (a2)+,d0
  5858.     beq.s    .D
  5859.     move.l    d0,a0
  5860.     cmp.b    #"+",(a0)    look for add-option
  5861.     bne.s    .B
  5862.     bsr    GetProtMask
  5863.     move.l    d0,temp5(a5)
  5864.     bra.s    .C
  5865. .B    cmp.b    #"-",(a0)    look for sub-option
  5866.     bne.s    .A
  5867.     bsr    GetProtMask
  5868.     move.l    d0,temp6(a5)
  5869. .C    move.l    a2,a0
  5870.     lea    -4(a2),a1
  5871. .E    move.l    (a0)+,(a1)+    delete this parm
  5872.     bne.s    .E
  5873.     subq.l    #4,a2
  5874.     bra.s    .A
  5875.  
  5876. .D    moveq    #-1,d0
  5877.     eor.l    d0,temp6(a5)
  5878.     bra    directory2    jump into dir-lister
  5879.  
  5880.  
  5881. GetProtMask    ;a0=bits-string, d0=bit-mask
  5882.     moveq    #0,d0
  5883.     addq.l    #1,a0
  5884. .B    move.b    (a0)+,d1
  5885.     beq.s    .C
  5886.     moveq    #7,d2
  5887. .A    cmp.b    protflags(pc,d2.w),d1
  5888.     bne.s    .D
  5889.     bset    d2,d0
  5890.     bra.s    .B
  5891. .D    dbra    d2,.A
  5892.     lea    badprotbit(pc),a1
  5893.     bsr    pr_stringlf
  5894.     bra    galactic
  5895. .C    rts
  5896.  
  5897. pr_prot    lea    temp2buf(a5),a0        V2.0
  5898. pr_pro2    moveq    #7,d0
  5899.     move.l    fib_Protection(a5),d1
  5900.     eor.b    #$0f,d1
  5901. .A    move.b    #"-",(a0)+
  5902.     btst    d0,d1
  5903.     beq.s    .B
  5904.     move.b    protflags(pc,d0.w),-1(a0)
  5905. .B    dbra    d0,.A
  5906.     clr.b    (a0)
  5907.     lea    temp2buf(a5),a1
  5908.     rts
  5909.  
  5910. protflags    dc.b    'dewrapsh'
  5911.  
  5912. *************************
  5913. *    JOIN        *    V2.3 new written
  5914. *************************
  5915. joinz    clr.l    temp2(a5)
  5916.     bset    #20,temp2+1(a5)    set join flag
  5917.     bsr    check_q_r
  5918.     clr.l    devproc(a5)
  5919.     clr.l    temp5(a5)    destination file
  5920.     clr.l    temp6(a5)    memory block
  5921.     lea    parm2(a5),a3
  5922.     addq.l    #4,a3
  5923.     tst.l    (a3)+
  5924.     beq    too_less_args    no arg given
  5925. .A    tst.l    (a3)+
  5926.     bne.s    .A
  5927.     move.l    -8(a3),a2    get last parm
  5928.     clr.l    -8(a3)        and remove it
  5929.     move.l    a2,d1
  5930.     move.l    #MODE_READWRITE,d2
  5931.     jsr    _LVOOpen(a6)
  5932.     move.l    d0,temp5(a5)    open output file and store it
  5933.     beq    DOSerr
  5934.     move.l    d0,d1
  5935.     moveq    #0,d2
  5936.     moveq    #1,d3
  5937.     jsr    _LVOSeek(a6)    look for end, no error checking
  5938.     bsr    GetCopyBlock
  5939.     beq    .F
  5940.     move.l    d0,temp6(a5)
  5941.     bsr    directory2    DO COPY !
  5942.     bsr    FreeCopyBlock
  5943. .F    move.l    temp5(a5),d1
  5944.     jsr    _LVOClose(a6)
  5945.     moveq    #RETURN_OK,d0
  5946.     rts
  5947.  
  5948. JoinFile    ;a0=filename, temp5=outfile, temp6=mem block
  5949.     moveq    #0,d4
  5950.     move.l    a0,d1
  5951.     move.l    #MODE_OLDFILE,d2
  5952.     jsr    _LVOOpen(a6)    open input file
  5953.     move.l    d0,d4        d4=input file handle
  5954.     beq    perr3
  5955.     move.l    temp5(a5),d5    d5=output file handle
  5956.     bsr    PerformCopy        Main Stuff !
  5957.     bne.s    .C
  5958.     lea    joinOK(pc),a1        all OK
  5959.     bsr    pr_string
  5960.     moveq    #RETURN_OK,d0
  5961. .C    rts
  5962.  
  5963. *************************
  5964. *    MOVE        *    V2.3
  5965. *************************
  5966. movez    clr.l    temp2(a5)
  5967.     bset    #22,temp2+1(a5)    set move flag
  5968.     bset    #21,temp2+1(a5)    set rename flag
  5969.     bset    #26,temp2(a5)    set delete flag
  5970.     clr.l    temp7(a5)    holds full dest. pathname
  5971.     bra.s    Copy1
  5972.  
  5973. MoveFile    ;Filename in a0
  5974.     move.l    a0,a3
  5975.     move.l    temp7(a5),a0    path
  5976.     move.l    a3,a1        name
  5977.     lea    temp2buf(a5),a2    path+name
  5978.     bsr    addpath
  5979.     move.l    a2,d2
  5980.     move.l    a3,d1
  5981.     jsr    _LVORename(a6)
  5982.     tst.l    d0
  5983.     beq.s    .A
  5984.     lea    moveOK(pc),a1
  5985.     bsr    pr_string
  5986.     moveq    #1,d0
  5987. .A    rts
  5988.  
  5989. *************************
  5990. *    COPY        *    V2.3 new written
  5991. *************************
  5992. copysize    = 50000
  5993. copyz    clr.l    temp2(a5)
  5994. Copy1    bset    #23,temp2+1(a5)    set copy flag
  5995.     bset    #30,temp2(a5)    bit 30=quick flag
  5996.     bsr    check_q_r
  5997.     clr.l    devproc(a5)
  5998.     clr.l    temp5(a5)    destination dir
  5999.     clr.l    temp6(a5)    memory block
  6000.     lea    parm2(a5),a2
  6001.     tst.l    (a2)+
  6002.     beq    too_less_args    *no arg given
  6003.     tst.l    (a2)+
  6004.     bne.s    Copy2
  6005.     lea    null(pc),a2    *one arg -> copy to current dir
  6006.     bra    Copy3b
  6007.  
  6008. Copy2    tst.l    (a2)+
  6009.     bne    Copy3
  6010.     move.l    -8(a2),a0    *two args -> copy to file/dir
  6011.     clr.l    -8(a2)        get it and remove it
  6012.     move.l    a0,a2
  6013.     move.l    parm2(a5),a0
  6014.     bsr    check_wild
  6015.     tst.l    d0
  6016.     beq    Copy3b        wildcards->copy to dir
  6017.     move.l    parm2(a5),d1
  6018.     btst.l    #22,temp2+1(a5)
  6019.     beq.s    .B        move: try to rename
  6020.     move.l    a2,d2
  6021.     jsr    _LVORename(a6)
  6022.     tst.l    d0
  6023.     beq.s    .B        move:    failed
  6024.     move.l    parm2(a5),a1        OK
  6025.     bsr    pr_string
  6026.     bsr    pr_space
  6027.     lea    moveOK(pc),a1
  6028.     bsr    pr_string
  6029.     moveq    #RETURN_OK,d0
  6030.     rts
  6031. .B    move.l    parm2(a5),d1
  6032.     move.l    #MODE_OLDFILE,d2    try to copy file to file:
  6033.     jsr    _LVOOpen(a6)    try to open input file    (d4)
  6034.     move.l    d0,d4
  6035.     beq.s    Copy3b        input not found->maybe a dir
  6036.     move.l    a2,d1
  6037.     move.l    #MODE_NEWFILE,d2
  6038.     jsr    _LVOOpen(a6)    try to open output file (d5)
  6039.     move.l    d0,d5
  6040.     bne.s    .D
  6041.     bsr    closett
  6042.     bra.s    Copy3b
  6043. .D    move.l    parm2(a5),a1
  6044.     bsr    pr_string
  6045.     bsr    pr_space
  6046.     bsr    GetCopyBlock
  6047.     bne.s    .A
  6048.     bsr    closett
  6049.     bra    resi_no_mem
  6050. .A    move.l    thistask(a5),a0
  6051.     move.l    pr_CurrentDir(a0),a3
  6052.     move.l    a3,temp5(a5)
  6053.     bsr    PerformCopy    do copy !
  6054.     move.l    d0,d4
  6055.     bsr    FreeCopyBlock
  6056.     tst.l    d4        error occured ?
  6057.     bne.s    .E
  6058.     btst    #22,temp2+1(a5)        move flag ?
  6059.     beq.s    .C
  6060.     move.l    parm2(a5),a0
  6061.     bsr    DoDelete    move: delete old file
  6062. .C    lea    copyOK(pc),a1        all OK
  6063.     bsr    pr_string
  6064. .E    move.l    d4,d0
  6065.     rts
  6066.  
  6067. Copy3    tst.l    (a2)+        *three or more args -> copy them to dir
  6068.     bne.s    Copy3        look for last parm
  6069.     move.l    -8(a2),a0    get it
  6070.     clr.l    -8(a2)        and remove it
  6071.     move.l    a0,a2
  6072. Copy3b    move.l    a2,d1
  6073.     moveq    #ACCESS_READ,d2
  6074.     jsr    _LVOLock(a6)    try to lock dir
  6075.     move.l    d0,d7
  6076.     bne.s    .B        found
  6077.     jsr    _LVOIoErr(a6)
  6078.     cmp.l    #205,d0        object not found ?
  6079.     beq.s    .C
  6080.     bra    pr_galactic    no
  6081. .C    move.l    a2,d1
  6082.     jsr    _LVOCreateDir(a6)    yes, make dir
  6083.     move.l    d0,d1
  6084.     beq    DOSerr
  6085.     jsr    _LVOUnLock(a6)    unlock and try again
  6086.     move.l    a2,a1
  6087.     bsr    pr_string
  6088.     bsr    pr_space
  6089.     lea    makedirOK(pc),a1
  6090.     bsr    pr_string
  6091.     bra.s    Copy3b
  6092. .B    bsr    fibexam2
  6093.     tst.l    fib_DirEntryType(a5)    file or dir ?
  6094.     bpl.s    .E
  6095.     move.l    d7,d1
  6096.     jsr    _LVOUnLock(a6)    was not a dir
  6097.     move.l    #212,d0
  6098.     bra    pr_galactic
  6099. .E    move.l    d7,temp5(a5)    was a dir: store lock
  6100.     lea    -80(sp),sp
  6101.     move.l    sp,temp7(a5)
  6102.     bsr    AdjustPath    move: get full path
  6103.     move.l    a2,d1
  6104.     jsr    _LVODeviceProc(a6)
  6105.     move.l    d0,devproc(a5)
  6106.     bsr    GetCopyBlock
  6107.     beq    .F
  6108.     bsr    directory2    DO COPY !
  6109.     bsr    FreeCopyBlock
  6110. .F    lea    80(sp),sp    space needed for move
  6111.     move.l    temp5(a5),d1
  6112.     jsr    _LVOUnLock(a6)    unlock dir
  6113.     moveq    #RETURN_OK,d0
  6114.     rts
  6115.  
  6116. GetCopyBlock
  6117.     move.l    #copysize,d0
  6118.     moveq    #1,d1
  6119.     bsr    iwantmem    get memory block
  6120.     move.l    d0,temp6(a5)
  6121.     rts
  6122.  
  6123. FreeCopyBlock
  6124.     move.l    temp6(a5),a1
  6125.     move.l    #copysize,d0
  6126.     bra    givemem        free memory block
  6127.  
  6128. CopyFileToDir    ;a0=filename
  6129. *current path set, destination path in temp5, memory block in temp6
  6130.     moveq    #0,d4
  6131.     moveq    #0,d5
  6132.     move.l    a0,a2
  6133.     move.l    a0,d1
  6134.     move.l    #MODE_OLDFILE,d2
  6135.     jsr    _LVOOpen(a6)    open input file
  6136.     move.l    d0,d4        d4=input file handle
  6137.     move.l    temp5(a5),d1
  6138.     bsr    CurrentDir
  6139.     move.l    d0,a3        a3 holds current dir
  6140.     tst.l    d4
  6141.     beq    perr3        read protected ?
  6142.     move.l    a2,a0
  6143.     lea    temp2buf(a5),a2
  6144.     move.l    a2,a1
  6145.     bsr    rempath
  6146.     move.l    a2,d1
  6147.     move.l    #MODE_NEWFILE,d2
  6148.     jsr    _LVOOpen(a6)    open output file
  6149.     move.l    d0,d5        d5=output file handle
  6150.     move.l    a3,d1
  6151.     bsr    CurrentDir
  6152.     tst.l    d5
  6153.     beq    perr3        already exits/disk full ?
  6154.     bsr    PerformCopy        Main Stuff !
  6155.     bne.s    .C
  6156.     cmp.l    fib_Size(a5),d6
  6157.     beq.s    .B
  6158.     lea    wrongsize(pc),a1    wrong size
  6159.     bsr    pr_string
  6160.     move.l    d6,d0
  6161.     bsr    print10
  6162.     bsr    pr_lf
  6163.     bra.s    .A
  6164. .B    lea    copyOK(pc),a1        all OK
  6165.     bsr    pr_string
  6166. .A    moveq    #RETURN_OK,d0
  6167. .C    rts
  6168.  
  6169. PerformCopy        ;dest. filename in a2, d4,d5:filehandles
  6170.     clr.l    d6        d6 holds filesize
  6171. .A    move.l    d4,d1
  6172.     move.l    temp6(a5),d2
  6173.     move.l    #copysize,d3
  6174.     jsr    _LVORead(a6)    read a block
  6175.     move.l    d0,d3
  6176.     bmi    perr2        read error ?
  6177.     beq.s    recoend
  6178.     move.l    d5,d1
  6179.     move.l    temp6(a5),d2
  6180.     jsr    _LVOWrite(a6)    write as much as read
  6181.     tst.l    d0
  6182.     bmi    perr2        disk full ?
  6183.     cmp.l    d0,d3
  6184.     bne    perr2        disk full ?
  6185.     add.l    d0,d6        sum up size in d6
  6186.     cmp.l    #copysize,d3
  6187.     bne.s    .B        buffer not filled by Read
  6188.     lea    dot(pc),a1
  6189.     bsr    pr_string    print dots as progress-indicator
  6190. .B    bsr    check_c        check for CTRL-C break
  6191.     beq.s    .A
  6192. recoend    bsr    closett
  6193. adjust    tst.l    devproc(a5)
  6194.     beq.s    .A
  6195.     move.l    temp5(a5),d1
  6196.     bsr    CurrentDir
  6197.     move.l    d0,a3
  6198.     move.l    a2,d1
  6199.     move.l    fib_Protection(a5),d2
  6200.     beq.s    .D
  6201.     jsr    _LVOSetProtection(a6)    set old protection
  6202.     tst.l    d0
  6203.     beq    perr1
  6204. .D    move.l    a2,d1
  6205.     lea    fib_Comment(a5),a0    copy comment
  6206.     tst.b    (a0)
  6207.     beq.s    .C
  6208.     move.l    a0,d2
  6209.     jsr    _LVOSetComment(a6)
  6210.     tst.l    d0
  6211.     beq    perr1
  6212. .C    bsr    clearArgs        set old date
  6213.     lea    fib_Date(a5),a0
  6214.     move.l    a0,myArg4(a5)
  6215.     move.l    devproc(a5),packettask(a5)
  6216.     move.l    temp5(a5),myArg2(a5)
  6217.     lea    NewPrintBuffer(a5),a1
  6218.     move.l    a1,d2
  6219.     lsr.l    #2,d2
  6220.     move.l    d2,myArg3(a5)
  6221.     addq.l    #1,a1
  6222.     moveq    #-1,d0
  6223. .B    addq.l    #1,d0
  6224.     move.b    (a2)+,(a1)+
  6225.     bne.s    .B
  6226.     move.b    d0,NewPrintBuffer(a5)
  6227.     moveq    #ACTION_SET_DATE,d0
  6228.     move.l    d0,packettype(A5)
  6229.     bsr    sendpacket
  6230.     tst.l    sp_res1(a5)
  6231.     beq    perr1
  6232.     move.l    a3,d1
  6233.     bsr    CurrentDir
  6234. .A    moveq    #RETURN_OK,d0
  6235.     rts
  6236.  
  6237. perr2
  6238. perr3    bsr    closett
  6239. perr1    jsr    _LVOIoErr(a6)
  6240.     cmp.l    #221,d0
  6241.     bne.s    .A
  6242.     move.b    #1,break_flag(a5)    break if disk is full
  6243. .A    bsr    pr_lf
  6244.     bsr    pr_DOSerr
  6245.     move.l    a3,d1
  6246.     bsr    CurrentDir
  6247.     moveq    #RETURN_ERROR,d0
  6248.     rts
  6249.  
  6250. closett    move.l    d4,d1    ;close files in d4 & d5
  6251.     beq.s    .A
  6252.     jsr    _LVOClose(a6)
  6253.     moveq    #0,d4
  6254. .A    btst    #20,temp2+1(a5)    join: do not close outfile
  6255.     bne.s    .C
  6256.     move.l    d5,d1
  6257.     beq.s    .B
  6258.     jsr    _LVOClose(a6)
  6259. .C    moveq    #0,d5
  6260. .B    rts
  6261.  
  6262.  
  6263.  
  6264. *************************************************************
  6265. ** ENTRY A0=name
  6266. ** EXIT  D0=address, D1=size
  6267. readfile    movem.l    d2-d6/a0-a4,-(sp)
  6268.     move.l    a0,d1
  6269.     move.l    a0,a4
  6270.     move.l    #MODE_OLDFILE,d2
  6271.     jsr    _LVOOpen(a6)    try to open it in current dir
  6272.     move.l    d0,d4    d4=handle
  6273.     bne.s    .A
  6274.     moveq    #-1,d1        Don't request
  6275.     bsr    changeWindowPtr
  6276.     lea    paths(pc),a0
  6277.     move.l    a4,a1
  6278.     lea    tempbuf(a5),a2
  6279.     bsr    addpath
  6280.     move.l    a2,d1
  6281.     move.l    #MODE_OLDFILE,d2
  6282.     jsr    _LVOOpen(a6)    try to open it in S: dir
  6283.     move.l    d0,d4
  6284.     beq    readerr
  6285.     moveq    #0,d1        request on
  6286.     bsr    changeWindowPtr
  6287.  
  6288. .A    moveq    #1,d3        open succeded
  6289.     moveq    #0,d2
  6290.     move.l    d4,d1
  6291.     jsr    _LVOSeek(a6)
  6292.     moveq    #-1,d3
  6293.     moveq    #0,d2
  6294.     move.l    d4,d1
  6295.     jsr    _LVOSeek(a6)
  6296.     move.l    d0,d5    d5=size, handles also powerpacked files
  6297.     moveq    #1,d1
  6298.     bsr    iwantmem
  6299.     beq    readerr2
  6300.     move.l    d0,d6    d6=addr
  6301.     move.l    d6,d2
  6302.     move.l    d5,d3
  6303.     move.l    d4,d1
  6304.     jsr    _LVORead(a6)    READ IT
  6305.     tst.l    d0
  6306.     bmi    readerr3
  6307.     move.l    d4,d1
  6308.     jsr    _LVOClose(a6)    close it
  6309.     move.l    d6,d0
  6310.     move.l    d5,d1
  6311.     movem.l    (sp)+,d2-d6/a0-a4
  6312.     rts
  6313. readerr3    move.l    d6,a1
  6314.     move.l    d5,d0
  6315.     bsr    givemem    ;NB won't work correctly if memory fail occurs.
  6316.             ;Will try to print DOS error for this
  6317. readerr2    move.l    d4,d1
  6318.     jsr    _LVOClose(a6)
  6319. readerr        moveq    #0,d1
  6320.     bsr    changeWindowPtr
  6321.     bra    DOSerr
  6322.  
  6323. *****************
  6324. *    MORE    *
  6325. *****************
  6326. morez    tst.l    parm2(a5)
  6327.     beq    too_less_args
  6328.     moveq    #0,d4
  6329.     move.l    parm3(a5),d0
  6330.     beq    .C
  6331.     move.l    d0,a1
  6332.     bsr    convert_ASCII_to_num
  6333.     beq    bad_number_error
  6334.     tst.w    d0
  6335.     beq.s    .C
  6336.     subq.w    #1,d0
  6337.     move.w    d0,d4
  6338.  
  6339. .C    move.l    parm2(a5),a0
  6340.     bsr    readfile
  6341.     moveq    #0,d2
  6342. ViewMore        ;Jump-In to review the buffer
  6343.     move.l    d0,-(sp)    push address
  6344.     move.l    d1,-(sp)    push size
  6345.     bsr    make_screen
  6346.     move.l    (sp)+,d0
  6347.     move.l    (sp)+,a1
  6348.     bsr    givemem
  6349.     moveq    #RETURN_OK,D0
  6350.     RTS
  6351.  
  6352. make_screen    * more main-routine, also used for help
  6353. * Entry: d0=start adress, d1=length, d4=number of lines or 0, d2=lookback
  6354.     movem.l    d0-d2,-(sp)
  6355.     addq.b    #1,noreview_flag(a5)
  6356.     clr.l    temp1(a5)
  6357.     tst.l    ConsoleSwitch(a5)
  6358.     bne.s    .F
  6359.     addq.l    #1,temp1(a5)
  6360.     move.l    thistask(a5),a3
  6361.     move.l    pr_ConsoleTask(a3),ConsoleSwitch(a5)
  6362.     bsr    raw_on
  6363. .F    btst    #FLcutline,Flags+3(a5)
  6364.     beq.s    .G
  6365.     lea    cutontx(pc),a1
  6366.     bsr    pr_string
  6367. .G    tst.w    d4
  6368.     bne.s    .A
  6369.     bsr    GetWinSize
  6370.     move.w    d0,d4
  6371. .A    movem.l    (sp)+,d0-d2
  6372.     move.w    d4,line_count(a5)
  6373.     move.l    d0,d5    d5=start
  6374.     move.l    d0,a4    a4=ptr
  6375.     move.l    d0,a3
  6376.     move.l     d0,d6
  6377.     add.l    d1,d6    d6=end addr
  6378.     tst.l    d2
  6379.     beq.s    mk_screen
  6380.     move.l    d6,a4
  6381.     bra    look_back
  6382. mk_screen
  6383.     lea    clrhide(pc),a1
  6384.     bsr    pr_string
  6385.     move.w    line_count(a5),d2
  6386.     move.l    a4,-(sp)
  6387.     moveq    #0,d0
  6388.     bra.s    .A
  6389. .C    moveq    #1,d0    PRINT SCREEN FULL OF LINES
  6390. .A;    bsr    pr_line
  6391. .B    cmp.l    d6,a4    check against end
  6392.     beq.s    .E
  6393.     move.b    (a4)+,d0
  6394.     cmp.b    #LF,d0
  6395.     bne.s    .B
  6396.     dbra    d2,.C
  6397.     move.l    a4,a3    A3 points to end of page marker    
  6398. .E    move.l    a4,d7    D7 points to end
  6399.     move.l    (sp)+,a4
  6400. ;    bra    waitabit
  6401.  
  6402.     move.l    a4,d2
  6403.     move.l    outhandle(a5),d1
  6404.     beq.s    waitabit
  6405.     move.l    d7,d3
  6406.     sub.l    a4,d3
  6407.     subq.l    #1,d3
  6408.     bmi.s    waitabit    don't print if 0
  6409.     cmp.l    d7,d6
  6410.     bne.s    .D
  6411.     cmp.l    a3,d7
  6412.     beq.s    .D
  6413.     addq.l    #1,d3
  6414. .D    jsr    _LVOWrite(a6)
  6415.  
  6416. waitabit    
  6417.     move.l    stdin(a5),d1
  6418.     beq    cloga
  6419.     lea    tempbytes(a5),a0
  6420.     move.l    a0,d2
  6421.     moveq    #1,d3
  6422.     jsr    _LVORead(a6)        wait for space key
  6423. .A    moveq    #0,d0            clear top bytes
  6424.     move.b    tempbytes(a5),d0    test byte of input line
  6425.     cmp.b    #$9b,d0
  6426.     beq.s    waitabit        CSI ? Try again !
  6427. tastes    cmp.b    #'a',d0
  6428. ;    blo.s    go_upper
  6429. ;    sub.b    #$20,d0
  6430.  
  6431. go_upper    cmp.b    #$42,d0        cursor down ?
  6432.     beq.s    .G
  6433.     cmp.b    #"2",d0
  6434.     bne.s    ck_up
  6435. .G    cmp.l    d7,d6
  6436.     beq    waitabit
  6437.     lea    scroll_up_tx(pc),a1    SCROLL UP ONE LINE,
  6438.     bsr    pr_string    SEND CURSOR TO START OF LINE
  6439. .B    cmp.l    d6,a4    advance one line
  6440.     beq.s    .C
  6441.     move.b    (a4)+,d0
  6442.     cmp.b    #LF,d0
  6443.     bne.s    .B
  6444. .C    cmp.l    d6,a3    move a3 down one line too
  6445.     beq.s    .D
  6446.     move.b    (a3)+,d0
  6447.     cmp.b    #LF,d0
  6448.     bne.s    .C
  6449. .D    move.l    a4,-(sp)
  6450.     move.l    d7,a4
  6451. ;    cmp.l    d7,d6
  6452. ;    beq.s    .A
  6453.     moveq    #0,d0
  6454.     bsr    pr_line    print line from d7
  6455. .A    cmp.l    d6,a4    advance D7 one line
  6456.     beq.s    .E
  6457.     move.b    (a4)+,d0
  6458.     cmp.b    #LF,d0
  6459.     bne.s    .A
  6460. .E    move.l    a4,d7
  6461.     move.l    (sp)+,a4
  6462.     bra    waitabit
  6463.  
  6464. ck_up    cmp.b    #$41,d0        V2.0    cursor up ?
  6465.     beq.s    .G
  6466.     cmp.b    #"8",d0
  6467.     bne.s    ck_fwd
  6468. .G    cmp.l    d5,a4
  6469.     beq    waitabit
  6470.     lea    scroll_down_tx(pc),a1    SCROLL DOWN ONE LINE,
  6471.     bsr    pr_string    SEND CURSOR TO TOP LEFT
  6472.     cmp.l    d5,a4
  6473.     bls.s    .E
  6474.     subq.l    #1,a4
  6475. .B    cmp.l    d5,a4
  6476.     beq.s    .A
  6477.     cmp.b    #LF,-(a4)
  6478.     bne.s    .B
  6479.     addq.l    #1,a4
  6480. .A    moveq    #0,d0
  6481.     bsr    pr_line
  6482. .E    move.l    d7,a3
  6483.     cmp.l    d5,a3
  6484.     beq.s    .C
  6485.     subq.l    #1,a3
  6486. .D    cmp.l    d5,a3
  6487.     beq.s    .C
  6488.     cmp.b    #LF,-(a3)
  6489.     bne.s    .D
  6490.     addq.l    #1,a3
  6491. .C    move.l    a3,d7
  6492.     lea    temp2buf(a5),a1
  6493.     move.b    #$9b,(a1)+
  6494.     move.w    line_count(a5),d0
  6495.     addq.w    #1,d0
  6496.     bsr    qpr10
  6497.     move.b    #"H",(a1)+
  6498.     clr.b    (a1)
  6499.     lea    temp2buf(a5),a1
  6500.     bsr    pr_string    CURSOR some lines down
  6501.     bra    waitabit
  6502.  
  6503. ck_fwd    cmp.b    #$43,d0            cursor right ?
  6504.     beq.s    .A
  6505.     cmp.b    #"3",d0
  6506.     beq.s    .A
  6507.     cmp.b    #" ",d0
  6508.     bne.s    ck_top
  6509. .A    cmp.l    d7,d6        one page forward
  6510.     beq    waitabit
  6511.     move.l    a3,a4
  6512.     bra    mk_screen
  6513. ck_top    cmp.b    #$54,d0            shift cursor up ?
  6514.     beq.s    .A
  6515.     cmp.b    #"7",d0
  6516.     bne.s    ck_bot
  6517. .A    cmp.l    d5,a4        start of text
  6518.     beq    waitabit
  6519.     move.l    d5,a4
  6520.     bra    mk_screen
  6521. ck_bot    cmp.b    #$53,d0            shift cursor down ?
  6522.     beq.s    .A
  6523.     cmp.b    #"1",d0
  6524.     bne.s    ck_back
  6525. .A    cmp.l    a3,d6        end of text
  6526.     beq    waitabit
  6527.     move.l    d6,a4
  6528.     bra.s    look_back
  6529. ck_back    cmp.b    #$44,d0            cursor left ?
  6530.     beq.s    .A
  6531.     cmp.b    #"9",d0
  6532.     beq.s    .A
  6533.     cmp.b    #8,d0
  6534.     bne.s    ck_skey
  6535. .A    cmp.l    d5,a4        one page back
  6536.     beq    waitabit
  6537. look_back
  6538.     move.w    line_count(a5),d1
  6539.     addq.w    #1,d1
  6540. mlook2    cmp.l    d5,a4    check against start
  6541.     beq.s    .E
  6542.     move.b    -(a4),d0
  6543.     cmp.b    #LF,d0
  6544.     bne.s    mlook2
  6545.     dbra    d1,mlook2
  6546.     lea    1(a4),a4
  6547. .E    bra    mk_screen
  6548.  
  6549. ck_skey    cmp.b    #"s",d0        V2.0    search string ?
  6550.     bne.s    ck_jkey
  6551.     bsr    raw_off
  6552.     lea    msearch(pc),a1
  6553.     bsr    pr_string
  6554.     lea    tempbuf(a5),a2
  6555.     move.b    (a2),d4        save first char
  6556.     move.l    a2,d2
  6557.     moveq    #120,d3
  6558.     move.l    stdin(a5),d1
  6559.     beq.s    .A
  6560.     jsr    _LVORead(a6)
  6561.     tst.l    d0
  6562.     bmi.s    .A
  6563.     move.l    a2,a1
  6564.     add.l    d0,a2
  6565.     subq.l    #1,a2
  6566.     move.b    d4,(a2)
  6567.     cmp.l    a1,a2        just pressed return ?
  6568.     beq.s    .B
  6569.     clr.b    (a2)    no
  6570. .B    move.l    d5,a3
  6571.     move.l    a4,a0
  6572.     bsr    find_end_of_line
  6573.     move.l    a0,a2
  6574.     move.l    d6,a0
  6575.     bsr    searchSTR
  6576.     cmp.b    #LF,d0
  6577.     bne.s    .A
  6578.     move.l    a1,a4    set begin of line on top
  6579.     bra.s    .C
  6580. .A    bsr    DisplayBeep
  6581. .C    bsr    raw_on
  6582.     bra    mk_screen
  6583.  
  6584. ck_jkey    cmp.b    #"j",d0        V2.3    jump to % ?
  6585.     bne.s    ck_wkey
  6586.     bsr    raw_off
  6587.     lea    mjump(pc),a1
  6588.     bsr    pr_string
  6589.     lea    tempbuf(a5),a2
  6590.     move.l    a2,d2
  6591.     moveq    #120,d3
  6592.     move.l    stdin(a5),d1
  6593.     beq.s    .A
  6594.     jsr    _LVORead(a6)
  6595.     tst.l    d0
  6596.     bmi.s    .A
  6597.     move.l    a2,a1
  6598.     add.l    d0,a2
  6599.     subq.l    #1,a2
  6600.     cmp.l    a1,a2        just pressed return ?
  6601.     beq.s    .A
  6602.     clr.b    (a2)    no
  6603.     bsr    convert_ASCII_to_num
  6604.     beq.s    .A
  6605.     moveq    #100,d1
  6606.     cmp.l    d1,d0
  6607.     bhi.s    .A
  6608.     move.l    d6,d1
  6609.     sub.l    d5,d1    calc % of size
  6610.     bsr    mult_32x32
  6611.     moveq    #100,d1
  6612.     bsr    div_32
  6613.     move.l    d5,a4
  6614.     add.l    d0,a4    new pointer
  6615.     bsr    raw_on
  6616.     moveq    #0,d1
  6617.     bra    mlook2    search begin of line
  6618. .A    bsr    raw_on
  6619.     bra    mk_screen
  6620.  
  6621. ck_wkey    cmp.b    #"w",d0        V2.3    write text to file (or print) ?
  6622.     bne.s    ck_hkey
  6623.     bsr    raw_off
  6624.     lea    mwrite(pc),a1
  6625.     bsr    pr_string
  6626.     lea    tempbuf(a5),a2
  6627.     move.l    a2,d2
  6628.     moveq    #120,d3
  6629.     move.l    stdin(a5),d1
  6630.     beq.s    .C
  6631.     jsr    _LVORead(a6)
  6632.     move.l    a2,a1
  6633.     add.l    d0,a2
  6634.     subq.l    #1,a2
  6635.     clr.b    (a2)        null-end
  6636.     cmp.l    a1,a2        just pressed return ?
  6637.     beq.s    .C        yes,quit
  6638.     move.l    a1,d1
  6639.     move.l    #MODE_NEWFILE,d2
  6640.     jsr    _LVOOpen(a6)
  6641.     move.l    d0,d4
  6642.     beq.s    .C
  6643.     move.l    d4,d1
  6644.     move.l    d5,d2
  6645.     move.l    d6,d3
  6646.     sub.l    d2,d3
  6647.     jsr    _LVOWrite(a6)
  6648.     move.l    d4,d1
  6649.     jsr    _LVOClose(a6)
  6650. .C    bsr    raw_on
  6651.     bra    mk_screen
  6652.  
  6653. ck_hkey    cmp.b    #"h",d0        V2.3    help info ?
  6654.     beq.s    .A
  6655.     cmp.b    #$3f,d0        help key ?
  6656.     bne.s    ck_rkey
  6657. .A    move.l    d6,d2
  6658.     sub.l    d5,d2
  6659.     move.l    d2,-(sp)
  6660.     move.l    a4,d0
  6661.     sub.l    d5,d0
  6662.     moveq    #100,d1
  6663.     bsr    mult_32x32
  6664.     move.l    d2,d1
  6665.     bsr    div_32
  6666.     move.w    d0,-(sp)
  6667.     move.l    sp,a1
  6668.     lea    helpmor(pc),a0
  6669.     bsr    new_print
  6670.     addq.l    #6,sp
  6671.     bra    waitabit
  6672.  
  6673. ck_rkey    cmp.b    #"r",d0        V2.3    resized window ?
  6674.     bne.s    unknown_key
  6675.     bsr    GetWinSize
  6676.     move.w    d0,line_count(a5)
  6677.     bra    mk_screen
  6678.  
  6679. unknown_key
  6680.     btst    #FLcutline,Flags+3(a5)    unknown key to exit !
  6681.     beq.s    .G
  6682.     lea    cutofftx(pc),a1
  6683.     bsr    pr_string
  6684. .G    lea    show_cursor(pc),a1
  6685.     bsr    pr_stringlf
  6686.     tst.l    temp1(a5)
  6687.     beq.s    .F
  6688.     bsr    raw_off
  6689.     clr.l    ConsoleSwitch(a5)
  6690. .F    clr.b    noreview_flag(a5)
  6691.     moveq    #RETURN_OK,d0
  6692.     rts
  6693.  
  6694. find_end_of_line
  6695. .B    cmp.l    d6,a0    check against end
  6696.     bhs.s    .A
  6697.     move.b    (a0)+,d0
  6698.     cmp.b    #LF,d0
  6699.     bne.s    .B
  6700.     lea    -1(a0),a0
  6701. .A    rts
  6702.  
  6703. ** PRINT STRING AT A4 ENDING IN LF
  6704. pr_line    movem.l    d0-d4/a0,-(sp)
  6705.     move.l    d0,d4
  6706.     move.l    a4,d2
  6707.     move.l    outhandle(a5),d1
  6708.     beq.s    .C
  6709.     move.l    a4,a0
  6710.     bsr    find_end_of_line
  6711.     sub.l    a4,a0
  6712.     move.l    a0,d3
  6713.     tst.l    d4
  6714.     beq.s    .A
  6715.     subq.l    #1,d2
  6716.     addq.l    #1,d3
  6717. .A    tst.l    d3
  6718.     beq.s    .C    don't print if 0
  6719.     jsr    _LVOWrite(a6)
  6720. .C    movem.l    (sp)+,d0-d4/a0
  6721.     rts
  6722.  
  6723. GetWinSize
  6724.     move.l    a2,-(sp)
  6725.     lea    askforsize(pc),a1
  6726.     bsr    pr_string
  6727. .B    move.l    stdin(a5),d1
  6728.     beq    cloga
  6729.     lea    tempbuf(a5),a2
  6730.     move.l    a2,d2
  6731.     moveq    #100,d3
  6732.     jsr    _LVORead(a6)    get size of window
  6733.     add.l    d0,a2
  6734.     cmp.b    #"r",-(a2)
  6735.     bne.s    .B
  6736.     moveq    #1,d1
  6737. .C    cmp.b    #";",-(a2)
  6738.     bne.s    .C
  6739.     dbra    d1,.C
  6740.     addq.l    #1,a2
  6741.     move.l    a2,a1
  6742.     bsr    convert_ASCII_to_num
  6743.     tst.l    d0
  6744.     beq.s    .D
  6745.     bpl.s    .E
  6746. .D    moveq    #10,d0
  6747. .E    subq.w    #1,d0
  6748.     move.l    (sp)+,a2
  6749.     rts
  6750.  
  6751. *****************
  6752. *    TYPE    *        Type out ASCII file command    
  6753. *****************
  6754. typez    tst.l    parm2(a5)
  6755.     beq    too_less_args
  6756.     move.l    parm2(a5),a0
  6757.     bsr    readfile
  6758.     bsr    rawh_off    MAKE SURE YOU CAN PRESS SPACE TO HOLD IT
  6759.     move.l    d0,-(sp)    push address
  6760.     move.l    d1,-(sp)    push size
  6761.     move.l    d0,a4    a4=ptr
  6762.     move.l     d0,d6
  6763.     add.l    d1,d6    d6=end addr
  6764. next_scr    bsr    pr_screen
  6765. freef1    move.l    (sp)+,d0
  6766.     move.l    (sp)+,a1
  6767.     bsr    givemem
  6768.     moveq    #RETURN_OK,D0
  6769.     RTS
  6770.  
  6771. ** ENTRY D6=end of file A4=current pos
  6772. pr_screen    bsr    check_c
  6773.     bne    type_break
  6774.     moveq    #0,d0
  6775.     bsr    pr_line
  6776.     bsr    pr_lf
  6777. .B    cmp.l    d6,a4    check against end
  6778.     bhs.s    type_break
  6779.     move.b    (a4)+,d0
  6780.     cmp.b    #LF,d0
  6781.     bne.s    .B
  6782.     bra.s    pr_screen
  6783. type_break
  6784.     moveq    #RETURN_OK,D0
  6785.     rts
  6786.  
  6787. ***********************
  6788. * EXECUTE SCRIPT FILE *
  6789. ***********************
  6790. executez    ;execute AmigaDOS script
  6791.     tst.l    parm2(a5)
  6792.     beq    too_less_args
  6793.     bsr    raw_off
  6794.     lea    tempbuf(a5),a0
  6795.     move.l    a0,d1
  6796.     lea    exectx(pc),a1
  6797. .A    move.b    (a1)+,(a0)+    "execute"
  6798.     bne.s    .A
  6799.     move.b    #" ",-1(a0)    space
  6800.     lea    CLIbuf(a5),a1
  6801. .B    move.b    (a1)+,(a0)+    filename & args
  6802.     bne.s    .B
  6803.     move.b    #LF,-1(a0)    linefeed
  6804.     lea    endcltx(pc),a1
  6805. .D    move.b    (a1)+,(a0)+    "endcli"
  6806.     bne.s    .D
  6807.     move.l    thistask(a5),a1
  6808.     move.l    pr_CIS(a1),d2
  6809.     move.l    pr_COS(a1),d3
  6810.     jsr    _LVOExecute(a6)    execute AmigaDOS script
  6811.     moveq    #RETURN_OK,d0
  6812.     rts
  6813.  
  6814. * Execute ZShell script
  6815. xz2    bsr    readfile    A0 pts to filename
  6816.     move.l    d0,a0
  6817.     cmp.l    #$000003f3,(a0)    is it executable ?
  6818.     beq.s    exerr
  6819.     addq.l    #4,sp        kill return address
  6820. xz3    move.l    d0,a0
  6821.     cmp.w    #"/*",(a0)
  6822.     beq.s    xrexx
  6823.     move.l    d1,scsize(a5)
  6824.     move.l    d0,scaddr(a5)
  6825.     move.l    d0,scptr(a5)
  6826.     move.b    #1,scflag(a5)    make shell think text lines are in memory
  6827.     clr.b    mult_comm_flag(a5)
  6828.     bra    chorus
  6829. exerr    moveq    #RETURN_ERROR,d0
  6830.     rts
  6831. xrexx    move.l    d0,a1        execute AREXX-script
  6832.     move.l    d1,d0
  6833.     bsr    givemem        kill script
  6834.     lea    CLIbuf(a5),a0
  6835.     move.l    parm1(a5),d0
  6836.     beq.s    .A
  6837.     move.l    d0,a1
  6838. .B    move.b    (a1)+,(a0)+    copy rexx-file to CLIbuf
  6839.     bne.s    .B
  6840. .A    lea    rexxtx(pc),a1
  6841.     move.l    a1,parm1(a5)
  6842.     bra    notfound    execute archie3
  6843.  
  6844. *****************
  6845. *    ECHO    *
  6846. *****************
  6847. echoz    lea    parm2(a5),a3
  6848.     move.l    (a3)+,d0
  6849.     beq.s    echo3
  6850.     bra.s    echo5
  6851. echo2    move.l    (a3)+,d0
  6852.     bne.s    echo4
  6853. echo3    moveq    #RETURN_OK,d0
  6854.     rts
  6855. echo4    bsr    pr_space
  6856. echo5    move.l    d0,a0
  6857.     move.l    a0,a1
  6858.     move.l    a0,a2
  6859.     bra.s    .C
  6860. .B    move.b    d0,(a2)+
  6861. .C    move.b    (a0)+,d0
  6862.     beq.s    .A
  6863.     cmp.b    #$5c,d0 ;\    Ignore Specialchar
  6864.     bne.s    .D
  6865.     move.b    (a0)+,d0
  6866.     bra.s    .B
  6867. .D    cmp.b    #'^',d0        ^-Character
  6868.     bne.s    .B
  6869.     move.b    (a0)+,d0
  6870.     cmp.b    #"*",d0
  6871.     bne.s    .G
  6872.     move.b    #$9b,d0
  6873.     bra.s    .B
  6874. .G    cmp.b    #"$",d0        Number given ?
  6875.     beq.s    .F
  6876.     cmp.b    #"0",d0
  6877.     blo.s    .E
  6878.     cmp.b    #"9",d0
  6879.     bhi.s    .E
  6880. .F    subq.l    #1,a0
  6881.     movem.l    d1/d2/a1,-(sp)
  6882.     move.l    a0,a1
  6883.     bsr    convert_ASCII_to_num
  6884.     lea    -1(a1),a0
  6885.     movem.l    (sp)+,d1/d2/a1
  6886.     cmp.b    #".",(a0)
  6887.     bne.s    .B
  6888.     addq.l    #1,a0
  6889.     bra.s    .B        Number was given
  6890. .E    and.b    #$3f,d0        Control Char
  6891.     bra.s    .B
  6892. .A    clr.b    (a2)+
  6893.     bsr    pr_string
  6894.     bra    echo2
  6895.  
  6896. *****************
  6897. *    CLS    *
  6898. *****************
  6899. clsz    lea    clstx(pc),a1
  6900.     bsr    pr_string
  6901.     moveq    #RETURN_OK,d0
  6902.     rts
  6903.  
  6904. ** MEM INFO :RETURN 3 LONGWORDS AT A0 -> FREE CHIP,FAST,TOTAL
  6905. memory_info
  6906.     movem.l    a0-a2/a6,-(sp)
  6907.     move.l    a0,a2
  6908.     move.l    4.w,a6
  6909.     jsr    _LVOForbid(a6)    ; don't let 'em change while we ask
  6910.     move.l    #MEMF_CHIP,d1    ; ok, check free chip
  6911.     jsr    _LVOAvailMem(a6)    ; ask system how much there is
  6912.     move.l    d0,(a2)
  6913.     move.l    #MEMF_FAST,d1    ; check fast mem avail
  6914.     jsr    _LVOAvailMem(a6)
  6915.     move.l    d0,4(a2)
  6916.     move.l    #MEMF_PUBLIC,d1     ; get all available memory
  6917.     jsr    _LVOAvailMem(a6)
  6918.     move.l    d0,8(a2)
  6919.     jsr    _LVOPermit(a6)
  6920.     movem.l    (sp)+,a0-a2/a6
  6921.     rts
  6922.  
  6923. *****************
  6924. *    AVAIL    *
  6925. *****************
  6926. availz    tst.l    parm2(a5)
  6927.     beq.s    .A
  6928.     move.l    parm2(a5),a0
  6929.     bsr    return_dash_option
  6930.     cmp.b    #'C',d0
  6931.     bne.s    .A
  6932.     bsr    giveman        free some memory
  6933.     move.l    4.w,a6
  6934.     moveq    #-1,d0        Free mem
  6935.     move.l    #$00002711,d1    MAGIC NUMBER (from FIDO-net)
  6936.     jsr    _LVOAllocMem(a6)
  6937.     jsr    _LVOForbid(a6)
  6938.     movea.l    a6,a0
  6939.     moveq    #72,d0
  6940.     add.l    d0,a0
  6941.     moveq    #15,d0        free 16 interrupts
  6942.     moveq    #-1,d1
  6943.     moveq    #12,d2
  6944. .B    add.l    d2,a0
  6945.     cmp.l    (a0),d1
  6946.     bne.s    .C
  6947.     cmp.l    4(a0),d1
  6948.     bne.s    .C
  6949.     clr.l    (a0)
  6950.     clr.l    4(a0)
  6951. .C    dbra    d0,.B
  6952.     jsr    _LVOPermit(a6)
  6953.     move.l    dosbase(a5),a6
  6954. .A    lea    -12(sp),sp    show mem
  6955.     lea    (sp),a0
  6956.     bsr    memory_info
  6957.     move.l    a0,a1
  6958.     lea    memess(pc),a0
  6959.     bsr    new_print    show memory
  6960.     lea    12(sp),sp
  6961.     moveq    #RETURN_OK,d0
  6962.     rts
  6963.  
  6964.  
  6965. * ALTER WINDOW PTR FOR THIS PROCESS. USE TO DISABLE REQUESTERS POPPING UP.
  6966. * ENTRY D1=0 (NORMAL)  D1=-1 (SUBNORMAL, no requesters).
  6967. changeWindowPtr
  6968.     movem.l    d1/a0,-(sp)
  6969.     tst.l    d1
  6970.     bne.s    .A
  6971.     move.l    windowptr(a5),d1
  6972. .A    move.l    thistask(a5),a0
  6973.     move.l    d1,pr_WindowPtr(a0)
  6974.     movem.l    (sp)+,d1/a0
  6975.     rts
  6976.  
  6977. raw_on    movem.l    d6/d7,-(sp)    switch console to raw mode
  6978.     btst    #FLhide,Flags+2(a5)
  6979.     beq.s    .A
  6980.     lea    show_cursor(pc),a1
  6981.     bsr    pr_string
  6982. .A    moveq    #-1,d6
  6983.     bra.s    raw_switch
  6984.  
  6985. rawh_off    movem.l    d6/d7,-(sp)    like raw_off,but hides the cursor
  6986.     btst    #FLhide,Flags+2(a5)
  6987.     beq.s    .A
  6988.     lea    hide_cursor(pc),a1
  6989.     bsr    pr_string
  6990. .A    moveq    #0,d6
  6991.     bra.s    raw_switch
  6992.  
  6993. raw_off    movem.l    d6/d7,-(sp)    switch console to normal mode
  6994.     moveq    #0,d6
  6995. ;    bra.s    raw_switch
  6996.  
  6997. *WINDOW TYPE CHANGER    
  6998. raw_switch
  6999.     move.l    ConsoleSwitch(a5),d7
  7000.     beq.s    .A
  7001.     move.l    d7,packettask(a5)
  7002.     bsr    clearArgs
  7003.     move.l    #ACTION_SCREEN_MODE,packettype(a5)
  7004.     move.l    d6,myArg1(a5)
  7005.     bsr    sendpacket
  7006. .A    movem.l    (sp)+,d6/d7
  7007.     rts
  7008.  
  7009. clearArgs movem.l    d0/a0,-(sp)
  7010.     lea    sp_node(a5),a0
  7011.     moveq    #16,d0    ;68bytes
  7012. .A    clr.l    (a0)+
  7013.     dbra    d0,.A
  7014.     movem.l    (sp)+,d0/a0
  7015.     rts
  7016.     
  7017. ** ENTRY Uses myArg1-myArg7, and packettask, packettype
  7018. sendpacket    tst.l    packettask(a5)
  7019.     beq.s    .A
  7020.     movem.l    d0-d1/a0-a2,-(sp)    V2.0 (new written)
  7021.     bsr    sendpacket2
  7022.     move.l    a2,a0
  7023.     jsr    _LVOWaitPort(a6)
  7024.     move.l    a2,a0
  7025.     jsr    _LVOGetMsg(a6)
  7026.     move.l    dosbase(a5),a6
  7027.     movem.l    (sp)+,d0-d1/a0-a2
  7028. .A    rts
  7029.  
  7030. sendpacket2    ;used by sendpacket and get_one_char
  7031.     move.l    4.w,a6
  7032.     move.b    #5,LN_TYPE+sp_node(a5)    message
  7033.     move.l    thistask(a5),a2
  7034.     lea    pr_MsgPort(a2),a2    Process-MsgPort !
  7035.     move.l    a2,sp_reply(a5)        Replyport
  7036.     move.l    a2,sp_port(a5)
  7037.     move.w    #dp_SIZEOF+4,sp_length(a5)
  7038.     lea    sp_link(a5),a0
  7039. ;    move.l    a0,sp_ptr(a5)
  7040.     move.l    a0,LN_NAME+sp_node(a5)    points to link
  7041.     lea    sp_node(a5),a1
  7042.     move.l    a1,sp_link(a5)        linked to itself
  7043.     move.l    packettask(a5),a0
  7044.     jsr    _LVOPutMsg(a6)
  7045.     rts
  7046.  
  7047. *************************
  7048. *    RELABEL     *
  7049. *************************
  7050. relabelz    tst.l    parm3(a5)
  7051.     beq    too_less_args
  7052.     move.l    parm2(a5),a0
  7053.     bsr    check_for_colon
  7054.     bne    no_col
  7055. .D    move.l    parm2(a5),d1    PARM2=DF0: etc
  7056.     jsr    _LVODeviceProc(a6)
  7057.     tst.l    d0
  7058.     beq    DOSerr
  7059.     move.l    d0,packettask(a5)
  7060.     move.l    #256,d0
  7061.     moveq    #1,d1
  7062.     bsr    iwantmem        ASSUME GETS 256 BYTES
  7063.     move.l    d0,a2        A2=destination
  7064.     lsr.l    #2,d0
  7065.     bsr    clearArgs
  7066.     move.l    d0,myArg1(a5)    BPTR to my string
  7067.     move.l    parm3(a5),a0    NewName
  7068.     lea    1(a2),a1        A1=after count
  7069.     moveq    #0,d0
  7070. .A    move.b    (a0)+,(a1)+
  7071.     addq.l    #1,d0
  7072.     cmp.b    #':',(a0)        ALLOW FOR IDIOTS WHO PUT : ON END
  7073.     beq.s    .C
  7074.     tst.b    (a0)
  7075.     bne.s    .A
  7076. .C    clr.b    (a1)
  7077.     move.b    d0,(a2)
  7078.     moveq    #ACTION_RENAME_DISK,d0
  7079.     move.l    d0,packettype(a5)    TYPE=RENAME_DISK
  7080.     bsr    sendpacket
  7081.     move.l    a2,a1
  7082.     move.l    #256,d0
  7083.     bsr    givemem
  7084.     bsr    changedisk    ;(moved to dc)
  7085. *    bsr    eval_CD        -IS MORE ELEGANT IF I LEAVE OUT.
  7086.     moveq    #RETURN_OK,d0    USER WILL HAVE TO TYPE CD TO CHANGE
  7087.     rts            PROPER.
  7088.  
  7089. *************************
  7090. *    ADDBUFFERS    *
  7091. *************************
  7092. addbuffersz
  7093.     cmp.w    #36,kickver(a5)
  7094.     blo.s    .A
  7095.     move.l    parm2(a5),d3
  7096.     beq    too_less_args
  7097.     move.l    parm3(a5),d0
  7098.     beq.s    .B
  7099.     move.l    d0,a1
  7100.     bsr    convert_ASCII_to_num
  7101.     beq    bad_number_error
  7102. .B    move.l    d3,d1
  7103.     move.l    d0,d2
  7104.     jsr    _LVOAddBuffers(a6)
  7105.     tst.l    d0
  7106.     beq    DOSerr
  7107.     moveq    #-1,d1
  7108.     cmp.l    d1,d0
  7109.     bne.s    .C
  7110.     jsr    _LVOIoErr(a6)
  7111. .C    move.l    d0,-(sp)
  7112.     move.l    d3,-(sp)
  7113.     lea    (sp),a1
  7114.     lea    addbufftx(pc),a0
  7115.     bsr    new_print
  7116.     addq.l    #8,sp
  7117.     bra.s    .D
  7118.  
  7119. .A    tst.l    parm3(a5)
  7120.     beq    too_less_args
  7121.     bsr    clearArgs
  7122.     move.l    parm3(a5),a1
  7123.     bsr    convert_ASCII_to_num
  7124.     beq    bad_number_error
  7125.     cmp.l    #32767,d0
  7126.     bhi    bad_number_error
  7127.     move.l    d0,myArg1(a5)
  7128.     move.l    parm2(a5),d1    PARM2=DF0: etc
  7129.     jsr    _LVODeviceProc(a6)
  7130.     tst.l    d0
  7131.     beq    DOSerr
  7132.     move.l    d0,packettask(a5)
  7133.     moveq    #ACTION_MORE_CACHE,d0
  7134.     move.l    d0,packettype(A5)
  7135.     bsr    sendpacket
  7136.     bsr    PKTerr
  7137. .D    moveq    #RETURN_OK,d0
  7138.     rts
  7139.  
  7140. *************************
  7141. *    DIE-Handler    *
  7142. *************************
  7143. diez    move.l    parm2(a5),d1
  7144.     beq    too_less_args
  7145.     move.l    d1,a0
  7146.     bsr    check_for_colon
  7147.     bne.s    .A
  7148.     bsr    clearArgs    ;kill filesystemhandler
  7149.     jsr    _LVODeviceProc(a6)    PARM2=DF0: etc
  7150.     tst.l    d0
  7151.     beq    DOSerr
  7152.     move.l    d0,packettask(a5)
  7153.     moveq    #ACTION_DIE,d0
  7154.     move.l    d0,packettype(A5)
  7155.     bsr    sendpacket
  7156.     bsr    PKTerr
  7157. .B    moveq    #RETURN_OK,d0
  7158.     rts
  7159.  
  7160. .A    move.l    d1,a2
  7161.     bsr    findtsk
  7162.     beq.s    .B
  7163.     move.l    pr_CIS(a0),d2
  7164.     move.l    pr_COS(a0),d3
  7165.     move.l    a0,a1
  7166.     move.l    4.w,a6
  7167.     jsr    _LVORemTask(a6)
  7168.     move.l    dosbase(a5),a6
  7169.     move.l    d2,d1
  7170.     beq.s    .C
  7171.     jsr    _LVOClose(a6)
  7172. .C    move.l    d3,d1
  7173.     beq.s    .D
  7174.     jsr    _LVOClose(a6)
  7175. .D    bra.s    .B
  7176.  
  7177. *************************
  7178. *    SETDATE        *
  7179. *************************
  7180. setdatez tst.l    parm2(a5)
  7181.     beq    too_less_args
  7182.     move.l    parm2(a5),a2
  7183.     bsr    clearArgs
  7184.     lea    date_mark(a5),a0
  7185.     lea    (a0),a3
  7186.     move.l    a0,myArg4(a5)    ;APTR datestamp
  7187.     bsr    get_time
  7188.     tst.l    parm3(a5)
  7189.     beq    nospda
  7190.     move.l    a2,d1
  7191.     moveq    #ACCESS_READ,d2
  7192.     jsr    _LVOLock(a6)
  7193.     move.l    d0,d7
  7194.     beq    DOSerr
  7195.     bsr    fibexam2
  7196.     move.l    d7,d1
  7197.     jsr    _LVOUnLock(a6)
  7198.     lea    -14(sp),sp
  7199.     lea    (sp),a0
  7200.     lea    fib_Date(a5),a1
  7201.     bsr    convert_time
  7202.     lea    parm3(a5),a0
  7203.     lea    (sp),a1
  7204.     bsr    settime
  7205.     move.w    12(sp),d1
  7206.     lea    14(sp),sp
  7207.     tst.l    d0
  7208.     beq    .B
  7209.     rts
  7210.  
  7211. .B    lea    (a3),a0
  7212.     move.l    d5,(a0)+    ;days
  7213.     divu    #60,d6
  7214.     move.w    d6,d0
  7215.     ext.l    d0
  7216.     move.l    d0,(a0)+    ;mins
  7217.     swap    d6
  7218.     mulu    #50,d6
  7219.     add.l    d1,d6
  7220.     move.l    d6,(a0)        ;ticks
  7221. nospda    move.l    a2,d1    ;filename
  7222.     jsr    _LVODeviceProc(a6)
  7223.     tst.l    d0
  7224.     beq    DOSerr
  7225.     move.l    d0,packettask(a5)
  7226.     move.l    a2,a0
  7227.     lea    temp2buf(a5),a1
  7228.     move.l    a1,a3
  7229.     bsr    split_wild    No wildcard ! Only separates filename !
  7230.     move.l    a2,d1
  7231.     moveq    #ACCESS_READ,d2
  7232.     jsr    _LVOLock(a6)
  7233.     move.l    d0,d7
  7234.     beq    DOSerr
  7235.     move.l    d0,myArg2(a5)    ;BPTR lock
  7236.     move.l    a3,a0
  7237.     lea    tempbuf(a5),a1
  7238.     moveq    #-1,d0
  7239.     bsr    cpBSTR
  7240.     move.l    d0,myArg3(a5)    ;BSTR filename
  7241.     moveq    #ACTION_SET_DATE,d0
  7242.     move.l    d0,packettype(A5)
  7243.     bsr    sendpacket
  7244.     move.l    d7,d1
  7245.     jsr    _LVOUnLock(a6)
  7246.     bsr    PKTerr
  7247.     moveq    #RETURN_OK,d0
  7248.     rts
  7249.  
  7250. *************************
  7251. *    DISKCHANGE    *
  7252. *************************
  7253. diskchangez
  7254.     tst.l    parm2(a5)
  7255.     beq    too_less_args
  7256.     move.l    parm2(a5),d1    PARM2=DF0: etc
  7257.     jsr    _LVODeviceProc(a6)
  7258.     tst.l    d0
  7259.     beq    DOSerr
  7260.     move.l    d0,packettask(a5)
  7261.     bsr    changedisk
  7262.     moveq    #RETURN_OK,d0
  7263.     rts
  7264.  
  7265. ** USES task in packettask
  7266. changedisk
  7267.     bsr    clearArgs
  7268.     moveq    #ACTION_INHIBIT,d0
  7269.     move.l    d0,packettype(a5)
  7270.     moveq    #-1,d0    ;1?
  7271.     move.l    d0,myArg1(a5)
  7272.     bsr    sendpacket
  7273.     bsr    PKTerr
  7274.     clr.l    myArg1(a5)
  7275.     bsr    sendpacket
  7276.     bsr    PKTerr
  7277.     rts
  7278.  
  7279. *************************
  7280. *    LOCK        *
  7281. *************************
  7282. lockz    move.l    parm3(a5),a0
  7283.     moveq    #-1,d7
  7284.     bsr    CheckOnOff
  7285.     bne.s    .B
  7286.     moveq    #0,d7
  7287. .B    move.l    parm2(a5),d1    PARM2=DF0: etc
  7288.     beq    too_less_args
  7289.     jsr    _LVODeviceProc(a6)
  7290.     tst.l    d0
  7291.     beq    DOSerr
  7292.     move.l    d0,packettask(a5)
  7293.     bsr    clearArgs
  7294.     move.l    #ACTION_WRITE_PROTECT,d0
  7295.     move.l    d0,packettype(a5)
  7296.     move.l    d7,myArg1(a5)
  7297.     bsr    sendpacket
  7298.     bsr    PKTerr
  7299.     moveq    #RETURN_OK,d0
  7300.     rts
  7301.  
  7302. *********************************
  7303. *    UNSET VARIABLE        *
  7304. *********************************
  7305. unsetz    lea    parm2(a5),a3
  7306.     move.l    (a3)+,d0
  7307.     bne.s    .A
  7308.     bsr    deallocate_sets
  7309.     bra.s    .B
  7310. .A    move.l    d0,a0
  7311.     bsr    check_if_set_already_there
  7312.     tst.l    d0
  7313.     beq    unset_failure
  7314.     move.l    d0,a1
  7315.     move.l    (a1),d2    GRAB NEXT SET POINTER
  7316.     move.l    set_size(a1),d0
  7317.     move.l    d1,a0    D1=prior set
  7318.     move.l    d2,(a0)    SKIP OVER SET TO DELETE
  7319.     bsr    givemem
  7320.     move.l    (a3)+,d0
  7321.     bne.s    .A
  7322. .B    moveq    #RETURN_OK,d0
  7323.     rts
  7324. unset_failure
  7325.     lea    temp2buf(a5),a2
  7326. pr_notfound    ;string in a2
  7327.     move.l    a2,a1
  7328.     bsr    pr_string
  7329.     lea    notfund(pc),a1
  7330.     bsr    pr_stringlf
  7331.     moveq    #RETURN_ERROR,d0
  7332.     rts
  7333.  
  7334. *********************************
  7335. *    SET VARIABLE KEY    *
  7336. *********************************
  7337. set_link    equ    0
  7338. set_size    equ    4
  7339. set_name    equ    8
  7340. set_defn    equ    24
  7341.  
  7342. set_funcz
  7343.     move.l    parm2(a5),d0        SEE IF ANY PARAMETERS TYPED
  7344.     beq.s    show_current_sets
  7345.     tst.l    parm3(a5)
  7346.     beq.s    show_current_sets    
  7347.     move.l    d0,a0        A0=parm2
  7348.     bsr    check_if_set_already_there
  7349.     tst.l    d0
  7350.     beq    create_new_set
  7351.     movem.l    a0-a1,-(sp)    * update old set
  7352.     move.l    d0,a1        first delete old one
  7353.     move.l    (a1),d2    GRAB NEXT SET POINTER
  7354.     move.l    set_size(a1),d0
  7355.     move.l    d1,a0    D1=prior set
  7356.     move.l    d2,(a0)    SKIP OVER SET TO DELETE
  7357.     bsr    givemem
  7358.     movem.l    (sp)+,a0-a1     and replace with new set
  7359.     bra    create_new_set
  7360.  
  7361. show_current_sets
  7362.     bsr    rawh_off
  7363.     move.l    first_set_defn(a5),d0
  7364.     beq    no_sets_to_show
  7365. show_next_set
  7366.     move.l    d0,a3
  7367.     lea    set_name(a3),a1
  7368.     bsr    pr_string
  7369.     bsr    pr_tab
  7370.     lea    set_defn(a3),a1
  7371.     bsr    pr_stringlf
  7372.     move.l    (a3),d0        CHECK NEXT SET ADDRESS
  7373.     bne    show_next_set
  7374. no_sets_to_show
  7375.     moveq    #RETURN_OK,d0
  7376.     rts
  7377.  
  7378. create_new_set        ;a0=name a1=def
  7379.     lea    tempbuf(a5),a3        GET BIG BLOCK
  7380.     lea    set_name(a3),a1
  7381.     bsr    cp_string        COPY SET NAME TO SPACE
  7382.     bsr    ConvertSemi
  7383.     lea    CLIbuf(a5),a0    use CLIbuf, end in a1
  7384. .D    move.b    (a0)+,d0
  7385.     beq.s    .C
  7386.     cmp.b    #" ",d0        search for space
  7387.     bne.s    .D
  7388. .E    move.b    (a0)+,d0
  7389.     cmp.b    #" ",d0        check multiple spaces
  7390.     beq.s    .E
  7391.     cmp.b    #$22,-1(a0)    check for "
  7392.     bne.s    .G
  7393.     cmp.b    #$22,-2(a1)    surrounded by " " ?
  7394.     bne.s    .G
  7395.     clr.b    -2(a1)
  7396.     addq.l    #1,a0
  7397. .G    lea    set_defn(a3),a1    store definition
  7398. .C    subq.l    #1,a0
  7399. .F    move.b    (a0)+,(a1)+
  7400.     bne.s    .F
  7401.     move.l    a1,d4        D4=after end
  7402.     sub.l    a3,a1        WORK OUT HOW BIG IS ACTUALLY
  7403.     move.l    a1,d0
  7404.     moveq    #1,d1
  7405.     bsr    iwantmem    allocate block big enough for everything
  7406.     beq.s    .A
  7407.     move.l    d0,a2
  7408.     move.l    a1,set_size(a2)
  7409.     move.l    first_set_defn(a5),d1
  7410.     move.l    d1,(a2)            new pts to old
  7411.     move.l    a2,first_set_defn(a5)
  7412.     lea    set_name(a2),a1    new block
  7413.     lea    set_name(a3),a0    temp block
  7414. .B    move.b    (a0)+,(a1)+
  7415.     cmp.l    a0,d4
  7416.     bne.s    .B
  7417. .A    moveq    #RETURN_OK,d0
  7418.     rts
  7419.  
  7420. check_if_set_already_there
  7421. * A0= set name
  7422.     movem.l    a0-a1,-(sp)
  7423.     lea    temp2buf(a5),a1
  7424.     bsr    cp_string
  7425.     bsr    search_sets
  7426.     movem.l    (sp)+,a0-a1
  7427.     rts
  7428.  
  7429. deallocate_sets
  7430.     move.l    first_set_defn(a5),d3
  7431.     beq    no_sets_to_lose
  7432. lose_next_set
  7433.     move.l    d3,a1
  7434.     move.l    (a1),-(sp)
  7435.     move.l    set_size(a1),d0
  7436.     bsr    givemem
  7437.     move.l    (sp)+,d3
  7438.     bne    lose_next_set
  7439.     clr.l    first_set_defn(a5)
  7440. no_sets_to_lose
  7441.     rts
  7442.  
  7443. ConvertSemi    ;convert \; into ; from/to CLIbuf
  7444.     lea    CLIbuf(a5),a0
  7445.     move.l    a0,a1
  7446.     moveq    #0,d1
  7447. .A    move.b    (a0)+,d0
  7448.     cmp.b    #$5c,d1    ;\
  7449.     bne.s    .D
  7450.     cmp.b    #";",d0
  7451.     bne.s    .D
  7452.     subq.l    #1,a1
  7453. .D    move.b    d0,(a1)+
  7454.     move.b    d0,d1
  7455.     bne.s    .A
  7456.     rts
  7457.  
  7458. *************************
  7459. *    RESIDENT    *    V2.0:uses the GLOBAL resident-list
  7460. *************************    (many things changed)
  7461. residentz    move.l    parm2(a5),d0    SEE IF ANY PARAMETERS TYPED
  7462.     beq    show_current_residents
  7463.     lea    parm2(a5),a3
  7464.     move.l    (a3),a0
  7465.     bsr    return_dash_option
  7466.     cmp.b    #'C',d0
  7467.     beq    kill_resi
  7468. next_resi    move.l    (a3)+,d0
  7469.     bne.s    .B
  7470.     moveq    #RETURN_OK,d0
  7471.     rts
  7472. .B    move.l    d0,a4        A4=parmName
  7473.     move.l    a3,-(sp)
  7474.     bsr    spaths2        SEARCH PATHS FOR THE COMMAND
  7475.     move.l    (sp)+,a3
  7476.     tst.l    d0
  7477.     beq    resi_not_found
  7478.     move.l    d0,-(sp)    push seglist
  7479.     move.l    a4,a0
  7480.     move.l    a4,a1
  7481.     bsr    rempath        SRC = DEST is OK
  7482.     bsr    search_res2    find if same name is on resi list
  7483.     move.l    (sp)+,d3
  7484.     move.l    d0,d1
  7485.     bne.s    .A
  7486.     bsr    create_resi
  7487.     bra.s    next_resi
  7488. .A    moveq    #1,d0
  7489.     cmp.l    resi_usecount(a0),d0
  7490.     bne.s    resi_inuse
  7491.     move.l    d0,resi_usecount(a0)
  7492.     move.l    d3,resi_seglist(a0)    new seglist
  7493.     jsr    _LVOUnLoadSeg(a6)    Unload old one with same name
  7494.     bra.s    next_resi
  7495.  
  7496. kill_resi    tst.l    (a3)+
  7497. .B    move.l    (a3)+,d0
  7498.     bne.s    .A
  7499.     moveq    #RETURN_OK,d0
  7500.     rts
  7501. .A    move.l    d0,a4
  7502.     move.l    a4,a0
  7503.     move.l    a4,a1
  7504.     bsr    rempath        SRC = DEST is OK
  7505.     bsr    search_res2    find if same name is on resi list
  7506.     move.l    d0,d1        gives d0,a0,d2
  7507.     beq.s    resi_not_found
  7508.     moveq    #1,d0
  7509.     cmp.l    resi_usecount(a0),d0
  7510.     bne.s    resi_inuse
  7511.     move.l    a0,a2
  7512.     move.l    d2,a0
  7513.     move.l    resi_link(a2),resi_link(a0)
  7514.     clr.l    resi_link(a2)
  7515.     jsr    _LVOUnLoadSeg(a6)    Unload old one with same name
  7516.     move.l    a2,d1
  7517.     lsr.l    #2,d1
  7518.     jsr    _LVOUnLoadSeg(a6)
  7519.     bra.s    .B
  7520.  
  7521. resi_not_found
  7522.     move.l    #205,d0
  7523.     bra.s    resi_error
  7524. resi_no_mem
  7525.     moveq    #103,d0
  7526.     bra.s    resi_error
  7527. resi_inuse
  7528.     move.l    #202,d0
  7529. resi_error
  7530.     move.l    dosbase(a5),a6
  7531.     bra    pr_galactic
  7532.  
  7533. create_resi        ;D3:SegList, A4:Name
  7534.     moveq    #resi_length,d0
  7535.     move.l    a4,a0
  7536. .A    addq.l    #1,d0    one more for lenght-byte
  7537.     tst.b    (a0)+
  7538.     bne.s    .A
  7539.     addq.l    #4,d0    4 more for segment-length
  7540.     addq.l    #7,d0    (7 more for and'ing needed by UnLoadSeg)
  7541.     moveq    #-4,d1
  7542.     and.l    d1,d0
  7543.     move.l    d0,d2
  7544.     moveq    #1,d1
  7545.     bsr    iwantmem
  7546.     beq.s    resi_no_mem
  7547.     addq.l    #4,d0
  7548.     move.l    d0,a2        D0=addr of resi_list_node
  7549.     move.l    d2,-4(a2)    save segment-length
  7550.     bsr    do_forbid
  7551.     bsr    resi_hand
  7552.     move.l    d0,resi_link(a2)
  7553.     move.l    a2,d0
  7554.     lsr.l    #2,d0
  7555.     move.l    d0,(a0)
  7556.     moveq    #1,d0
  7557.     move.l    d0,resi_usecount(a2)
  7558.     move.l    d3,resi_seglist(a2)
  7559.     lea    resi_name(a2),a1
  7560.     move.l    a4,a0
  7561.     moveq    #-1,d0
  7562.     bsr    cpBSTR
  7563.     bsr    do_permit
  7564.     moveq    #0,d0
  7565.     rts
  7566.  
  7567. resi_hand    move.l    dl_Root(a6),a0
  7568.     move.l    rn_Info(a0),a0
  7569.     add.l    a0,a0
  7570.     add.l    a0,a0
  7571.     lea    di_NetHand(a0),a0    NetHand in A0
  7572.     move.l    (a0),d0        Start of Resi-List in D0
  7573.     rts
  7574.  
  7575. show_current_residents
  7576.     lea    residetx(pc),a1
  7577.     bsr    pr_stringlf
  7578.     bsr    rawh_off
  7579.     bsr    resi_hand
  7580.     beq    no_resis_to_show
  7581. .A    lsl.l    #2,d0
  7582.     move.l    d0,a3
  7583.     move.l    resi_usecount(a3),d0
  7584.     subq.l    #1,d0
  7585.     bsr    print10
  7586.     bsr    pr_space
  7587. ;    move.l    a3,d0
  7588. ;    bsr    printADR
  7589. ;    bsr    pr_space
  7590.     lea    resi_name(a3),a1
  7591.     moveq    #0,d3
  7592.     move.b    (a1)+,d3
  7593.     move.l    a1,d2
  7594.     move.l    outhandle(a5),d1
  7595.     beq.s    .B
  7596.     jsr    _LVOWrite(a6)
  7597.     bsr    pr_lf
  7598. .B    bsr    check_c
  7599.     bne.s    no_resis_to_show
  7600.     move.l    resi_link(a3),d0
  7601.     bne    .A
  7602. no_resis_to_show
  7603.     moveq    #RETURN_OK,d0
  7604.     rts
  7605.  
  7606. ******    Copy String from A0 to BSTR A1
  7607. cpBSTR    movem.l    d1-d2/a0-a2,-(sp)    max. Length-2 in D0
  7608.     lea    1(a1),a2
  7609.     moveq    #0,d2
  7610.     bra.s    .B
  7611. .A    move.b    d1,(a2)+
  7612.     addq.l    #1,d2
  7613. .B    move.b    (a0)+,d1
  7614.     dbeq    d0,.A
  7615.     clr.b    (a2)    ;NULL-end it
  7616.     move.b    d2,(a1)
  7617.     move.l    a1,d0
  7618.     lsr.l    #2,d0
  7619.     movem.l    (sp)+,d1-d2/a0-a2    D0 is BPTR to the BSTR
  7620.     rts
  7621.  
  7622.  
  7623. *********************************
  7624. *    RPN CALCULATOR        *
  7625. *********************************
  7626. evalz    lea    parm2(a5),a4
  7627.     move.l    sp,d5        remember the stack ptr
  7628. rpn_loop1    move.l    (a4)+,d1
  7629.     beq    show_rpn_result
  7630.     lea    endofparms(a5),a1
  7631.     cmp.l    a1,a4
  7632.     bhi    show_rpn_result
  7633.     move.l    d1,a1
  7634.     lea    8(sp),a0
  7635.     cmp.l    a0,d5
  7636.     blo    not_poke32
  7637.  
  7638.     cmp.b    #'+',(a1)        
  7639.     bne.s    not_add        
  7640.     move.l    (sp)+,d0        DO ADD
  7641.     add.l    d0,(sp)
  7642.     bra    rpn_loop1
  7643. not_add    cmp.b    #'-',(a1)
  7644.     bne.s    not_sub
  7645.     move.l    (sp)+,d0
  7646.     sub.l    d0,(sp)
  7647.     bra    rpn_loop1
  7648.     
  7649. not_sub    cmp.b    #'*',(a1)
  7650.     bne.s    not_mult
  7651.     move.l    (sp)+,d0    last    DO MULT
  7652.     move.l    (sp)+,d1    2nd last
  7653.     bsr    mult_32x32
  7654.     move.l    d0,-(sp)
  7655.     bra    rpn_loop1
  7656. not_mult    cmp.b    #'/',(a1)
  7657.     bne.s    not_div
  7658.     move.l    (sp)+,d1    last    DO DIVIDE
  7659.     move.l    (sp)+,d0    2nd last
  7660.     tst.l    d1
  7661.     beq    rpn_error        NO DIVIDE BY ZERO
  7662.     bsr    div_32
  7663.     move.l    d0,-(sp)
  7664.     bra    rpn_loop1
  7665. not_div    cmp.b    #'&',(a1)
  7666.     bne.s    not_and
  7667.     move.l    (sp)+,d0
  7668.     and.l    d0,(sp)
  7669.     bra    rpn_loop1
  7670. not_and    cmp.b    #"|",(a1)
  7671.     bne.s    not_or
  7672.     move.l    (sp)+,d0
  7673.     or.l    d0,(sp)
  7674.     bra    rpn_loop1
  7675. not_or    cmp.b    #'!',(a1)
  7676.     bne.s    not_poke32
  7677.     move.l    (sp)+,d0    GET ADDR        DO POKE 32
  7678.     move.l    (sp)+,d1    GET VALUE
  7679.     and.b    #$fe,d0
  7680.     move.l    d0,a0
  7681.     move.l    d1,(a0)
  7682.     bra    rpn_loop1
  7683. not_poke32
  7684.     cmp.b    #'@',(a1)
  7685.     bne.s    not_peek32
  7686.     move.l    (sp)+,d0    ADDR    DO PEEK 32
  7687.     cmp.l    sp,d5
  7688.     blo    rpn_error
  7689.     and.b    #$fe,d0
  7690.     move.l    d0,a0
  7691.     move.l    (a0),-(sp)
  7692.     bra    rpn_loop1
  7693.  
  7694. not_peek32
  7695.     bsr    convert_ASCII_to_num
  7696.     beq    rpn_error
  7697.     move.l    d0,-(sp)
  7698.     bra    rpn_loop1
  7699. rpn_error    move.l    d5,sp
  7700.     rts
  7701.  
  7702. show_rpn_result
  7703.     move.l    (sp),-(sp)
  7704.     moveq    #RETURN_ERROR,d7    error on equal
  7705.     tst.l    (sp)
  7706.     beq.s    .B
  7707.     bpl.s    .C
  7708.     moveq    #RETURN_WARN,d7        warn on minus
  7709.     bra.s    .B
  7710. .C    moveq    #RETURN_OK,d7        ok on plus
  7711. .B    lea    (sp),a1
  7712.     move.l    sp,a1
  7713.     lea    rpn_result_tx(pc),a0    print hex & dec
  7714.     move.l    outhandle(a5),d0
  7715.     cmp.l    stdout(a5),d0    output redirected ?
  7716.     beq.s    .A
  7717.     moveq    #RETURN_OK,d7
  7718.     lea    rpn_res2(pc),a0    print only number
  7719. .A    bsr    new_print
  7720.     move.l    d5,sp
  7721.     move.l    d7,d0
  7722.     rts
  7723.  
  7724. div_32    movem.l    d2-d4,-(sp)    ;d0=d0/d1
  7725.     moveq    #0,d2
  7726.     moveq    #31,d4
  7727. _divu1    roxl.l    #1,d0    ; divident
  7728.     roxl.l    #1,d2    ; work accum
  7729.     cmp.l    d1,d2    ; cmp with divisor
  7730.     blo.s    _divu2
  7731.     sub.l    d1,d2
  7732.     dc.l    $003c0010    ;ori.b    #16,CCR    ;setx
  7733. _divu2    roxl.l    #1,d3    ; result
  7734.     dbf    d4,_divu1
  7735.     move.l    d3,d0
  7736.     move.l    d2,d1
  7737.     movem.l    (sp)+,d2-d4    ;result:d0 rest:d1
  7738.     rts
  7739.  
  7740.  
  7741. mult_32x32
  7742. * D1 = 32 bit, D0 = 32 bit (result)
  7743.     movem.l    d1-d3,-(sp)
  7744.     move.l    d0,d2
  7745.     move.l    d0,d3
  7746.     mulu    d1,d0    save intermediate result
  7747.     swap    d3
  7748.     mulu    d1,d3
  7749.     swap    d3
  7750.     clr.w    d3
  7751.     add.l    d3,d0
  7752.     swap    d1
  7753.     mulu    d1,d2
  7754.     swap    d2
  7755.     clr.w    d2
  7756.     add.l    d2,d0
  7757.     movem.l    (sp)+,d1-d3
  7758.     rts
  7759.  
  7760. * Convert null ending ASCII number(A1) to 32bit number in D0
  7761. * Return D1=0 if bad number (a1:current pos)
  7762. convert_ASCII_to_num    
  7763.     movem.l    d2/d3/a0,-(sp)
  7764.     moveq    #0,d3    SET POSITIVE
  7765.     moveq    #0,d1    RESET BASE
  7766. .A    cmp.b    #'|',(a1)
  7767.     bne.s    convnor
  7768.     lea    1(a1),a0
  7769.     bsr    readfile
  7770.     cmp.w    #NEWPRINTSIZE-2,d1
  7771.     bhs    conversion_finished
  7772.     move.l    d0,a0
  7773.     lea    NewPrintBuffer(a5),a1
  7774.     move.l    d1,d2
  7775.     subq.w    #1,d2
  7776. .B    move.b    (a0)+,(a1)+
  7777.     dbra    d2,.B
  7778.     clr.b    (a1)
  7779.     move.l    d0,a1
  7780.     move.l    d1,d0
  7781.     bsr    givemem
  7782.     lea    NewPrintBuffer(a5),a1
  7783. ;    bset    #0,d3
  7784.     bra.s    .A
  7785. convnor    moveq    #0,d0    RESET RESULT
  7786.     moveq    #0,d1    RESET BASE
  7787.     tst.b    (a1)
  7788.     beq    conversion_finished
  7789.     moveq    #LF,d1    SET THE BASE
  7790.     cmp.b    #'-',(a1)    negative sign
  7791.     bne.s    .A
  7792.     bset    #3,d3
  7793. .D    addq.l    #1,a1
  7794. .A    cmp.b    #'+',(a1)    positive sign
  7795.     beq.s    .D
  7796.     cmp.b    #'&',(a1)    for APTR (hex!) -> BPTR
  7797.     bne.s    .B
  7798.     addq.l    #1,a1
  7799.     bset    #1,d3
  7800.     moveq    #16,d1    SET RADIX16
  7801.     bra    same_base
  7802. .B    cmp.b    #'§',(a1)    for BPTR (hex!) -> APTR
  7803.     bne.s    .C
  7804.     addq.l    #1,a1
  7805.     bset    #2,d3
  7806.     moveq    #16,d1    SET RADIX16
  7807.     bra    same_base
  7808. .C    cmp.b    #'$',(a1)
  7809.     bne.s    other_base
  7810.     move.b    (a1)+,d2    DUMMY BUMP
  7811.     moveq    #16,d1    SET RADIX16
  7812.     bra    same_base
  7813.  
  7814. other_base
  7815.     cmp.b    #'%',(a1)
  7816.     bne.s    same_base
  7817.     move.b    (a1)+,d2
  7818.     moveq    #2,d1    SET RADIX2
  7819. same_base    moveq    #0,d2
  7820.     move.b    (a1)+,d2
  7821.     beq    conversion_finished
  7822.     bsr    convert_D2_to_num
  7823.     tst.l    d1
  7824.     beq.s    conversion_finished
  7825.     bsr    mult_32x32
  7826.     add.l    d2,d0
  7827.     bra    same_base
  7828. conversion_finished
  7829.     btst    #3,d3
  7830.     beq.s    .A
  7831.     neg.l    d0
  7832. .A    btst    #1,d3
  7833.     beq.s    .B
  7834.     lsr.l    #2,d0
  7835. .B    btst    #2,d3
  7836.     beq.s    .C
  7837.     lsl.l    #2,d0
  7838. .C    movem.l    (sp)+,d2/d3/a0
  7839.     tst.b    d1
  7840.     rts
  7841.     
  7842. convert_D2_to_num
  7843.     cmp.b    #'0',d2
  7844.     blo.s    bad_number
  7845.     cmp.b    #'9',d2
  7846.     bhi.s    check_hex
  7847.     sub.b    #'0',d2
  7848.     rts
  7849. check_hex    cmp.b    #16,d1
  7850.     bne.s    bad_number
  7851.     cmp.b    #'f',d2
  7852.     bhi.s    bad_number
  7853.     cmp.b    #'A',d2
  7854.     blo.s    bad_number
  7855.     cmp.b    #'F',d2
  7856.     bhi.s    check_upper_hex
  7857.     sub.b    #55,d2
  7858.     rts
  7859. check_upper_hex
  7860.     cmp.b    #'a',d2
  7861.     blo.s    bad_number
  7862.     sub.b    #87,d2
  7863.     rts
  7864. bad_number
  7865.     moveq    #0,d1    FLAG ERROR thru silly base
  7866.     rts
  7867.  
  7868. *********************************
  7869. *    MEMORY EXAMINE        *
  7870. *********************************
  7871. memexamz    clr.l    mem_offset_addr(a5)
  7872.     moveq    #0,d7
  7873.     tst.l    parm2(a5)        CHECK IF NO ADDRESS.
  7874.     bne.s    .E
  7875.     moveq    #8,d7
  7876.     bra    show_mempage
  7877. .E    bsr    fixpam32
  7878.     tst.b    (a1)
  7879.     beq.s    .A
  7880.     move.l    a0,-(sp)
  7881.     bsr    convert_ASCII_to_num    convert 2nd num
  7882.     move.l    (sp)+,a0
  7883.     tst.b    d1
  7884.     beq    bad_number_error
  7885.     move.l    d0,d7            D7=2nd num
  7886. .A    move.l    a0,a1
  7887.     bsr    convert_ASCII_to_num    convert 1st num
  7888.     beq    bad_number_error
  7889. .C    tst.l    d7
  7890.     bne.s    .D
  7891.     moveq    #8,d7
  7892.     bra.s    memex2
  7893. .D    sub.l    d0,d7
  7894.     lsr.l    #4,d7
  7895.     addq.l    #1,d7
  7896.  
  7897. memex2    move.l    d0,mem_addr(a5)
  7898. show_mempage
  7899.     and.b    #$fe,mem_addr+3(a5)    MAKE SURE EVEN ADDRESS
  7900. shmem2    bsr    check_c
  7901.     bne    .A
  7902.     bsr    show_16_locs
  7903.     subq.l    #1,d7        D7=count
  7904.     bne.s    shmem2
  7905. .A    moveq    #RETURN_OK,d0
  7906.     rts
  7907.     
  7908. show_16_locs
  7909.     move.l    mem_addr(a5),a1
  7910.     lea    CLIbuf(a5),a3
  7911.     move.l    a3,a0
  7912.     moveq    #15,d0
  7913. sh_16_1    move.b    (a1)+,d1
  7914.     move.b    #'.',(a0)+
  7915.     move.b    d1,d2
  7916.     bclr    #7,d2
  7917.     cmp.b    #' ',d2
  7918.     blo.s    sh_16_2
  7919.     move.b    d1,-1(a0)
  7920. sh_16_2    dbra    d0,sh_16_1
  7921.     clr.b    (a0)
  7922.     move.l    a3,-(sp)        PUSH STRING ADDR
  7923.     move.l    -(a1),-(sp)    PUSH LAST BYTES
  7924.     move.l    -(a1),-(sp)
  7925.     move.l    -(a1),-(sp)
  7926.     move.l    -(a1),-(sp)    PUSH FIRST BYTES
  7927.     move.l    mem_addr(a5),d0
  7928.     sub.l    mem_offset_addr(a5),d0
  7929.     move.l    d0,-(sp)
  7930.     lea    mem_line(pc),a0
  7931.     lea    (sp),a1
  7932.     bsr    new_print
  7933.     movem.l    (sp)+,d0-d5    DUMMY
  7934.     add.l    #16,mem_addr(a5)
  7935.     rts
  7936.  
  7937. * ENTRY A0=FORMATSTRING A1=DATASTREAM.
  7938. new_print    ;v2.0 small data
  7939.     movem.l    d0-d3/a0-a3,-(sp)
  7940.     lea    NewPrintBuffer(a5),a3    ;V2.0 not on stack
  7941.     lea    KPutChar(pc),a2
  7942.     move.l    4.w,a6
  7943.     jsr    _LVORawDoFmt(a6)
  7944.     move.l    dosbase(a5),a6
  7945.     move.l    outhandle(a5),d1
  7946.     beq.s    .B
  7947.     lea    NewPrintBuffer(a5),a0
  7948.     move.l    a0,d2
  7949.     moveq    #-1,d3
  7950. .A    addq.l    #1,d3
  7951.     tst.b    (a0)+
  7952.     bne.s    .A
  7953.     jsr    _LVOWrite(a6)
  7954. .B    movem.l    (sp)+,d0-d3/a0-a3
  7955.     rts
  7956.  
  7957. KPutChar move.b    d0,(a3)+
  7958.     rts
  7959.  
  7960. GetDiskInfo    ;device-task must be in packettask(a5), gets info to a5
  7961.     bsr    clearArgs
  7962.     moveq    #ACTION_DISK_INFO,d0
  7963.     move.l    d0,packettype(a5)
  7964.     move.l    a5,d0
  7965.     lsr.l    #2,d0
  7966.     move.l    d0,myArg1(a5)    use FIB as INFO (bptr)
  7967.     bra    sendpacket
  7968.  
  7969. CountLocks    ;Exit: d0=number of all locks in system
  7970.     movem.l    d1/d2/a2,-(sp)
  7971.     clr.l    temp3(a5)
  7972.     bsr    do_forbid
  7973.     bsr    get_first_devinfo
  7974. .D    moveq    #dlt_device,d1
  7975.     bsr    find_next_assign    walk through dos-list
  7976.     tst.l    d0
  7977.     bne.s    .C
  7978.     move.l    8(a0),packettask(a5)    task
  7979.     beq.s    .D        was non-disk-device
  7980.     bsr    GetDiskInfo
  7981.     move.l    id_InUse(a5),d0    lock
  7982.     beq.s    .D
  7983. .A    addq.l    #1,temp3(a5)    count locks
  7984.     lsl.l    #2,d0
  7985.     move.l    d0,a0
  7986.     move.l    (a0),d0
  7987.     bne.s    .A
  7988.     bra.s    .D
  7989. .C    bsr    do_permit
  7990.     move.l    temp3(a5),d0
  7991.     movem.l    (sp)+,d1/d2/a2
  7992.     rts
  7993.  
  7994. ** SAVE STATS store current time in date mark, and current memory use in mem mark
  7995. save_mem_time
  7996.     movem.l    d0-d1/a0-a1,-(sp)
  7997.     clr.l    temp2(a5)
  7998.     btst    #FLcheck,Flags+3(a5)
  7999.     beq.s    .C
  8000.     move.l    4.w,a0
  8001.     tst.w    296(a0)        CPU better than 68000 ?
  8002.     bne.s    .A
  8003.     move.l    #1024,d0    no, store lower memory
  8004.     moveq    #1,d1
  8005.     bsr    iwantmem
  8006.     move.l    d0,temp2(a5)
  8007.     beq.s    .A
  8008.     move.l    d0,a1
  8009.     sub.l    a0,a0        adress 0 to 1023
  8010.     move.l    #1024/4-1,d0
  8011. .B    move.l    (a0)+,(a1)+
  8012.     dbra    d0,.B
  8013. .A    bsr    CountLocks
  8014.     lea    mem_mark(a5),a0
  8015.     bsr    memory_info    remember memory usage
  8016. .C    lea    date_mark(a5),a0
  8017.     bsr    get_time    remember this time
  8018.     movem.l    (sp)+,d0-d1/a0-a1
  8019.     rts
  8020.  
  8021. ** DISPLAY TIME ELAPSED SINCE LAST CALL TO SAVE TIME AND
  8022. **  ALSO CHANGE IN MEMORY AVAILABLE. EXPECTS RETURN CODE TO BE ABOVE RETURN
  8023. **  ADDRESS ON STACK ie 4(sp)
  8024. show_status
  8025.     lea    -34(sp),sp
  8026.     lea    (sp),a0        A0=time area
  8027.     move.l    Result2(a5),(a0)+    -4(a0) ioerr-result
  8028.     bsr    get_time    
  8029.     lea    date_mark(a5),a1
  8030.     move.l    ds_Tick(a0),d0
  8031.     sub.l    ds_Tick(a1),d0
  8032.     bpl.s    no_tick_carry
  8033.     add.l    #3000,d0
  8034.     subq.l    #1,ds_Minute(a0)
  8035. no_tick_carry
  8036.     move.l    d0,ds_Tick(a1)    store in datemark
  8037.     move.l    ds_Minute(a0),d0
  8038.     sub.l    ds_Minute(a1),d0
  8039.     move.l    d0,ds_Minute(a1)
  8040.     bsr    convert_time    A0=4+3 words of time
  8041. do_mem_deltas
  8042.     lea    14(a0),a0
  8043.     bsr    memory_info
  8044.     lea    mem_mark(a5),a1
  8045.     move.l    (a1),d0
  8046.     sub.l    d0,(a0)    subtract old from new    ;chip
  8047.     move.l    4(a1),d0
  8048.     sub.l    d0,4(a0)            ;fast
  8049.     move.l    8(a1),d0
  8050.     sub.l    d0,8(a0)            ;total
  8051.     lea    -12(a0),a1
  8052.     move.l    -18(a0),(a1)
  8053.     lea    stat_text(pc),a0
  8054.     bsr    new_print
  8055.     lea    34(sp),sp
  8056.     move.l    temp3(a5),d1    check for forgotten locks
  8057.     bsr    CountLocks
  8058.     cmp.l    d1,d0
  8059.     beq.s    .D
  8060.     exg.l    d0,d1
  8061.     movem.l    d0/d1,-(sp)
  8062.     move.l    sp,a1
  8063.     lea    lockleft(pc),a0
  8064.     bsr    new_print
  8065.     addq.l    #8,sp
  8066. .D    move.l    temp2(a5),d0
  8067.     beq.s    .A
  8068.     move.l    d0,a1        show changes of low memory
  8069.     sub.l    a0,a0
  8070.     move.l    #1024/4-1,d0
  8071. .B    move.l    (a0)+,d1
  8072.     cmp.l    (a1)+,d1
  8073.     beq.s    .C
  8074.     movem.l    a0-a1,-(sp)
  8075.     move.l    -4(a0),-(sp)
  8076.     move.l    -4(a1),-(sp)
  8077.     move.l    a0,-(sp)
  8078.     subq.l    #4,(sp)
  8079.     move.l    sp,a1
  8080.     lea    lowmemtx(pc),a0    print the changes
  8081.     bsr    new_print
  8082.     lea    12(sp),sp
  8083.     movem.l    (sp)+,a0-a1
  8084. .C    dbra    d0,.B
  8085.     move.l    temp2(a5),a1
  8086.     move.l    #1024,d0
  8087.     bsr    givemem
  8088. .A    rts
  8089.  
  8090. *************************    
  8091. *    DATE/TIME    *
  8092. *************************
  8093. datez    lea    date_mark(a5),a2
  8094.     move.l    a2,a0
  8095.     bsr    get_time
  8096.     move.l    a2,a1
  8097.     lea    -14(sp),sp
  8098.     lea    (sp),a0
  8099.     bsr    convert_time
  8100.     tst.l    parm2(a5)
  8101.     beq.s    .A
  8102.     lea    parm2(a5),a0
  8103.     lea    (sp),a1
  8104.     bsr.s    settime
  8105.     lea    14(sp),sp
  8106.     bne.s    .B
  8107.     bsr    tset
  8108.     clr.l    parm2(a5)
  8109.     bra.s    datez    ;now print date/time
  8110. .A    lea    (sp),a1
  8111.     lea    time_text(pc),a0
  8112.     bsr    new_print
  8113.     lea    14(sp),sp
  8114.     moveq    #RETURN_OK,d0
  8115. .B    rts
  8116.  
  8117. settime    movem.l    d1-d4/a0-a4,-(sp)    V2.0
  8118.     move.l    a0,a4        ;a0=parameters
  8119.     move.l    a1,temp1(a5)    ;a1=date/time
  8120. settim    move.l    (a4)+,a0
  8121.     lea    temp2buf(a5),a2
  8122.     moveq    #2,d3
  8123. aa1    move.l    a0,a1
  8124.     bsr    gab
  8125.     move.b    d0,d4
  8126.     beq.s    bb1
  8127.     clr.b    -1(a0)
  8128.     cmp.b    #".",d0        ;day.month.year
  8129.     bne.s    dat2
  8130. bb1    bsr    convert_ASCII_to_num
  8131.     cmp.w    #99,d0    ;rough check
  8132.     bhi    muell
  8133.     move.w    d0,(a2)+
  8134.     tst.l    d1
  8135.     beq    muell
  8136.     tst.b    d4
  8137.     dbeq    d3,aa1
  8138. mull1    tst.w    d3
  8139.     bne    muell
  8140.     lea    temp2buf(a5),a2
  8141.     move.l    temp1(a5),a1
  8142.     moveq    #2,d3
  8143. .B    move.w    (a2)+,(a1)+
  8144.     dbra    d3,.B
  8145.     bra    oktt
  8146. aa2    move.l    a0,a1
  8147.     bsr    gab
  8148.     move.b    d0,d4
  8149.     beq.s    bb2
  8150.     clr.b    -1(a0)
  8151. dat2    cmp.b    #":",d0        ;hour:minute:second
  8152.     bne.s    dat3
  8153. bb2    bsr    convert_ASCII_to_num
  8154.     cmp.w    #99,d0
  8155.     bhi    muell
  8156.     move.w    d0,(a2)+
  8157.     tst.l    d1
  8158.     beq    muell
  8159.     tst.b    d4
  8160.     dbeq    d3,aa2
  8161. mull2    tst.w    d3
  8162.     bne    muell
  8163.     lea    temp2buf(a5),a2
  8164.     move.l    temp1(a5),a1
  8165.     lea    6(a1),a1
  8166.     moveq    #2,d3
  8167. .B    move.w    (a2)+,(a1)+
  8168.     dbra    d3,.B
  8169.     bra    oktt
  8170.     moveq    #2,d3
  8171. aa3    move.l    a0,a1
  8172.     bsr    gab
  8173.     move.b    d0,d4
  8174.     beq.s    bb3
  8175.     clr.b    -1(a0)
  8176. dat3    cmp.b    #"-",d0        ;month-day-year
  8177.     bne    muell
  8178. bb3    bsr    convert_ASCII_to_num
  8179.     cmp.w    #99,d0
  8180.     bhi    muell
  8181.     move.w    d0,(a2)+
  8182.     tst.l    d1
  8183.     beq    muell
  8184.     tst.b    d4
  8185.     dbeq    d3,aa3
  8186. mull3    tst.w    d3
  8187.     bne    muell
  8188.     lea    temp2buf(a5),a2
  8189.     move.l    temp1(a5),a1
  8190.     move.w    (a2)+,2(a1)
  8191.     move.w    (a2)+,(a1)
  8192.     move.w    (a2)+,4(a1)
  8193. oktt    tst.l    (a4)
  8194.     bne    settim
  8195.     lea    chaotab(pc),a0
  8196.     move.l    temp1(a5),a1
  8197.     lea    temp2buf(a5),a3
  8198.     moveq    #5,d0
  8199.     moveq    #0,d1
  8200. .A    move.b    (a0)+,d1
  8201.     move.w    0(a1,d1),d2
  8202.     move.b    d2,(a3)+
  8203.     dbra    d0,.A
  8204.     lea    temp2buf(a5),a3
  8205.     bsr    calcsec
  8206.     movem.l    (sp)+,d1-d4/a0-a4
  8207.     moveq    #RETURN_OK,d0
  8208.     rts    ;result in d5-d7
  8209.  
  8210. muell    lea    muell_tx(pc),a1
  8211.     bsr    pr_stringlf
  8212.     movem.l    (sp)+,d1-d4/a0-a4
  8213.     moveq    #RETURN_ERROR,d0
  8214.     rts
  8215.  
  8216. gab    move.b    (a0)+,d0
  8217.     cmp.b    #$30,d0
  8218.     blo.s    .A
  8219.     cmp.b    #$39,d0
  8220.     bls.s    gab
  8221. .A    cmp.b    #"%",d0    ;handle bin (that's fun !)
  8222.     beq.s    gab
  8223.     rts
  8224.  
  8225. ** GET TIME STORE DAYS,MINUTES,TICKS AT A0
  8226. get_time    move.l    a0,-(sp)
  8227.     move.l    a0,d1
  8228.     jsr    _LVODateStamp(a6)
  8229.     move.l    (sp)+,a0
  8230.     rts
  8231.  
  8232. ** ENTRY A0 pts to 7 words of storage, A1 pts to date stamp
  8233. ** send time to A0 --> 13(A0)
  8234. convert_time
  8235.     movem.l    d0-d3/a0-a2,-(sp)
  8236.     move.l    ds_Tick(a1),d0
  8237.     divu    #50,d0
  8238.     move.w    d0,4+6(a0)        seconds
  8239.     swap    d0
  8240.     asl.w    #1,d0
  8241.     move.w    d0,6+6(a0)        hundredths
  8242.     move.l    ds_Minute(a1),d0
  8243.     divu    #60,d0
  8244.     move.w    d0,0+6(a0)        hours
  8245.     swap    d0    
  8246.     move.w    d0,2+6(a0)        minutes
  8247.     move.l    ds_Days(a1),d0
  8248.     move.w    #365,d1        V2.0:year, day, month
  8249.     move.w    #77,d2
  8250. wdhj    addq.w    #1,d2
  8251.     sub.w    d1,d0
  8252.     bcs.s    mon
  8253.     move.w    d2,d3
  8254.     and.w    #3,d3
  8255.     bne.s    wdhj
  8256.     cmp.w    #100,d2
  8257.     blo.s    ork
  8258.     moveq    #1,d3
  8259.     addq.w    #1,d0
  8260.     sub.w    #100,d2
  8261. ork    subq.w    #1,d0
  8262.     bcc.s    wdhj
  8263.     addq.w    #1,d0
  8264. mon    add.w    d1,d0
  8265.     move.w    d2,4(a0)    year (lots of work)
  8266.     moveq    #0,d2
  8267.     lea    montab(pc),a2
  8268. wdhm    addq.w    #1,d2
  8269.     moveq    #0,d1
  8270.     move.b    (a2)+,d1
  8271.     sub.w    d1,d0
  8272.     bcs.s    tag
  8273.     cmp.w    #2,d2
  8274.     bne.s    wdhm
  8275.     move.w    4(a0),d3
  8276.     beq.s    wdhm
  8277.     and.w    #3,d3
  8278.     bne.s    wdhm
  8279.     subq.w    #1,d0
  8280.     bcc.s    wdhm
  8281.     addq.w    #1,d0
  8282. tag    add.w    d1,d0
  8283.     addq.w    #1,d0
  8284.     move.w    d2,2(a0)    month (i don't like february)
  8285.     move.w    d0,(a0)        day
  8286.     movem.l    (sp)+,d0-d3/a0-a2
  8287.     rts
  8288.  
  8289. montab    dc.b    31,28,31,30,31,30,31,31,30,31,30,31
  8290.  
  8291. *************************
  8292. *    STACK        *
  8293. *************************
  8294. stackz    move.l    CLIptr(a5),a4
  8295.     move.l    cli_DefaultStack(a4),d7
  8296.     lsl.l    #2,d7
  8297.     tst.l    parm2(a5)
  8298.     beq.s    show_stack
  8299.     move.l    parm2(a5),a1
  8300.     bsr    convert_ASCII_to_num
  8301.     beq    bad_number_error
  8302. stk_num_OK
  8303.     move.l    d0,d6
  8304.     cmpi.l    #1600,d6  ;allow 1600 bytes for DOS
  8305.     blt.s    stoosmall
  8306.     move.l    d6,d0
  8307.     moveq    #1,d1   
  8308.     bsr    iwantmem 
  8309.     beq.s    stoobig   
  8310.     move.l    d0,a1   
  8311.     move.l    d6,d0   
  8312.     bsr    givemem  
  8313.     
  8314.     lsr.l    #2,d6
  8315.     move.l    d6,cli_DefaultStack(a4)
  8316.     moveq    #RETURN_OK,d0
  8317.     rts
  8318. stoosmall
  8319.     move.l    #-148,d0
  8320.     bra    pr_galactic
  8321. stoobig
  8322.     bra    resi_no_mem
  8323. show_stack
  8324.     move.l    d7,-(sp)
  8325.     move.l    #-146,d0
  8326.     bsr    GetMessage
  8327.     lea    (sp),a1
  8328.     bsr    new_print
  8329.     move.l    (sp)+,d0
  8330.     moveq    #RETURN_OK,d0
  8331.     rts
  8332.  
  8333. ** CHECK STRING A0 IF ENDING IN :
  8334. ** RETURN EQ IF DOES END IN COLON
  8335. check_for_colon
  8336. .A    tst.b    (a0)+    MAKE SURE ENDS IN :
  8337.     bne.s    .A
  8338.     move.b    -2(a0),d0
  8339.     cmp.b    #':',d0
  8340.     rts
  8341.  
  8342. do_forbid    move.l    4.w,a6
  8343.     jsr    _LVOForbid(a6)
  8344.     move.l    dosbase(a5),a6
  8345.     rts
  8346. do_permit    move.l    4.w,a6
  8347.     jsr    _LVOPermit(a6)
  8348.     move.l    dosbase(a5),a6
  8349.     rts
  8350.     
  8351. *************************
  8352. *    ASSIGN         *
  8353. *************************
  8354. assignz    cmp.w    #36,kickver(a5)
  8355.     blo    assi13
  8356.     tst.l    parm2(a5)
  8357.     beq    assi13
  8358.     move.l    parm3(a5),d2
  8359.     beq    too_less_args
  8360.     move.l    parm2(a5),a2
  8361.     move.l    a2,a0
  8362.     bsr    check_for_colon
  8363.     bne.s    .G
  8364.     clr.b    -2(a0)    no colon-end
  8365. .G    lea    assignuse(pc),a1
  8366.     move.l    parm4(a5),d0
  8367.     bne.s    .B
  8368.     move.l    d2,a0
  8369.     bsr    CheckOpt
  8370.     beq.s    .C
  8371.     move.l    d2,d1        Assign LOCK
  8372.     moveq    #-2,d2
  8373.     jsr    _LVOLock(a6)
  8374.     move.l    d0,d7
  8375.     move.l    d0,d2
  8376.     beq    DOSerr
  8377.     move.l    a2,d1
  8378.     jsr    _LVOAssignLock(a6)
  8379.     tst.l    d0
  8380.     beq    DOSerrUL
  8381.     bra    .A
  8382. .C    move.l    a2,d1        Assign REMOVE
  8383.     moveq    #0,d2
  8384.     jsr    _LVOAssignLock(a6)
  8385.     tst.l    d0
  8386.     beq    DOSerr
  8387.     bra.s    .A
  8388.  
  8389. .B    move.l    d0,a0
  8390.     bsr    CheckOpt
  8391.     bne.s    .H
  8392.     move.l    d2,d1        Assign REMOVE part
  8393.     moveq    #-2,d2
  8394.     jsr    _LVOLock(a6)
  8395.     move.l    d0,d7
  8396.     move.l    d0,d2
  8397.     beq    DOSerr
  8398.     move.l    a2,d1
  8399.     jsr    _LVORemAssignList(a6)
  8400.     tst.l    d0
  8401.     beq    DOSerrUL
  8402.     bra.s    .A
  8403. .H    bsr    CheckOpt
  8404.     bne.s    .D
  8405.     move.l    d2,d1        Assign ADD
  8406.     moveq    #-2,d2
  8407.     jsr    _LVOLock(a6)
  8408.     move.l    d0,d7
  8409.     move.l    d0,d2
  8410.     beq    DOSerr
  8411.     move.l    a2,d1
  8412.     jsr    _LVOAssignAdd(a6)
  8413.     tst.l    d0
  8414.     beq    DOSerrUL
  8415.     bra.s    .A
  8416. .D    bsr    CheckOpt
  8417.     bne.s    .E
  8418.     move.l    a2,d1        Assign PATH
  8419.     jsr    _LVOAssignPath(a6)
  8420.     tst.l    d0
  8421.     beq    DOSerr
  8422.     bra.s    .A
  8423. .E    bsr    CheckOpt
  8424.     bne.s    .F
  8425.     move.l    a2,d1        Assign DEFER
  8426.     jsr    _LVOAssignLate(a6)
  8427.     tst.l    d0
  8428.     beq    DOSerr
  8429.     bra.s    .A
  8430. .F    lea    assignuse(pc),a1
  8431.     bsr    pr_stringlf
  8432. .A    moveq    #RETURN_OK,d0
  8433.     rts
  8434.  
  8435. assi13    bsr    do_forbid        FORBID
  8436.     bsr    get_first_devinfo
  8437.     tst.l    parm2(a5)
  8438.     beq    show_assigns
  8439.     tst.l    parm3(a5)
  8440.     beq    exit_assignf    ONLY TWO PARMS TYPED (NEED 3)
  8441.     move.l    parm2(a5),a0
  8442.     bsr    check_for_colon
  8443.     beq    assi14
  8444.     bsr    do_permit
  8445. no_col    move.l    #210,d0
  8446.     bra    pr_galactic
  8447.     
  8448. assi14    moveq    #dlt_directory,d1    CREATE/MODIFY ASSIGN ******
  8449.     bsr    find_next_assign
  8450.     tst.l    d0
  8451.     bne    no_more_dir_assigns
  8452.     move.l    a0,d5
  8453.     move.l    parm2(a5),a0    A0=assigned name[0]
  8454.     moveq    #0,d2
  8455.     move.b    (a1)+,d2        get char count
  8456. .A    move.b    (a1)+,d0
  8457.     move.b    (a0)+,d1
  8458.     beq.s    assi14
  8459.     subq.l    #1,d2
  8460.     bmi.s    .C
  8461.     bsr    compD1D0nocase
  8462.     beq.s    .A
  8463. .D    bra.s    assi14
  8464.  
  8465. .C    cmp.b    #':',d1    CHANGE EXISTING
  8466.     bne.s    .D
  8467.     bsr    do_permit        PERMIT
  8468.     move.l    d5,a2        GOT A MATCH
  8469.     moveq    #ACCESS_READ,d2
  8470.     move.l    parm3(a5),d1
  8471.     jsr    _LVOLock(a6)
  8472.     tst.l    d0
  8473.     beq    exit_assignp
  8474.     move.l    d0,a3
  8475.     bsr    do_forbid        FORBID
  8476.     move.l    dvi_Lock(a2),d4
  8477.     move.l    a3,dvi_Lock(a2)    new lock
  8478.     add.l    a3,a3
  8479.     add.l    a3,a3
  8480.     move.l    fl_Task(a3),dvi_Task(a2)
  8481.     clr.l    dvi_Handler(a2)
  8482.     clr.l    dvi_StackSize(a2)
  8483.     clr.l    dvi_Priority(a2)
  8484.     clr.l    dvi_Startup(a2)
  8485.     clr.l    dvi_SegList(a2)
  8486.     clr.l    dvi_GlobVec(a2)
  8487.     bsr    do_permit
  8488.     move.l    d4,d1
  8489.     jsr    _LVOUnLock(a6)
  8490.     bra    exit_assignp
  8491.     
  8492. no_more_dir_assigns
  8493.     bsr    do_permit        CREATE NEW ASSIGN
  8494.     moveq    #48,d0
  8495.     move.l    #MEMF_CLEAR+1,d1
  8496.     bsr    iwantmem
  8497.     beq    exit_assignp
  8498.     move.l    d0,a4
  8499.     move.l    #48,(a4)+        save size byte
  8500.     move.l    parm2(a5),a0
  8501.     moveq    #4,d0    4+1 extra bytes for dos(nb: : is ignored)
  8502. .A    addq.l    #1,d0
  8503.     tst.b    (a0)+
  8504.     bne.s    .A
  8505.     move.l    d0,d3    D3=size+5+1    (block size|char_count|chars)
  8506.     moveq    #1,d1
  8507.     bsr    iwantmem
  8508.     beq    rem_dvi
  8509.     move.l    d0,a3
  8510.     move.l    d0,d4        D4=string ptr
  8511.     move.l    d3,(a3)+        save size byte
  8512.     subq.l    #6,d3
  8513.     move.b    d3,(a3)+        save char_count
  8514.     move.l    parm2(a5),a0
  8515.     bra.s    .C
  8516. .B    move.b    d1,(a3)+        copy string to NAME
  8517. .C    move.b    (a0)+,d1
  8518.     cmp.b    #':',d1
  8519.     bne.s    .B
  8520.     clr.b    (a3)        ;NULL-ending V2.0
  8521.     addq.l    #4,d0
  8522.     lsr.l    #2,d0    convert to bstr
  8523.     move.l    d0,dvi_Name(a4)
  8524.     move.l    #dlt_directory,dvi_Type(a4)
  8525.     moveq    #ACCESS_READ,d2
  8526.     move.l    parm3(a5),d1
  8527.     jsr    _LVOLock(a6)
  8528.     tst.l    d0
  8529.     beq    rem_str
  8530.     move.l    d0,dvi_Lock(a4)
  8531.     lsl.l    #2,d0        x 4
  8532.     move.l    d0,a0
  8533.     move.l    fl_Task(a0),dvi_Task(a4)
  8534.     bsr    do_forbid
  8535.     bsr    get_first_devinfo    RETURNS A1 pts info substr, A2 pts 1st devinfo
  8536.     move.l    a2,dvi_Next(a4)
  8537.     move.l    a4,d0
  8538.     lsr.l    #2,d0
  8539.     move.l    d0,di_DevInfo(a1)    Insert new top of chain
  8540.     bsr    do_permit
  8541.     
  8542.     bra.s    exit_assignp
  8543. rem_str    move.l    d4,a1
  8544.     move.l    (a1),d0
  8545.     bsr    givemem
  8546. rem_dvi    lea    -4(a4),a1
  8547.     moveq    #48,d0
  8548.     bsr    givemem
  8549. exit_assignp
  8550.     moveq    #RETURN_OK,d0
  8551.     rts
  8552. exit_assignf
  8553.     bsr    do_permit
  8554.     moveq    #RETURN_OK,d0
  8555.     rts
  8556.     
  8557. * SHOW ASSIGNS    ALREADY IN FORBID STATE
  8558. show_assigns
  8559.     lea    -8(sp),sp
  8560.     move.l    a2,(sp)        0(sp)= BPTR of first devinfo
  8561.     move.l    #5000,d0
  8562.     moveq    #1,d1
  8563.     bsr    iwantmem        allocate big block
  8564.     beq    asg_fail
  8565.     move.l    d0,a4        A4 = string block
  8566.     move.l    d0,a3
  8567.     add.l    #5000,a3    A3 = end of string block
  8568.     move.l    d0,4(sp)        4(sp) = string block
  8569.     lea    volume_tx(pc),a0    PRINT VOLUMES:
  8570.     bsr    copy_name
  8571.     moveq    #dlt_volume,d1
  8572. do_volumes
  8573. .E    bsr    find_next_assign    COPY ALL DEVICES THAT MATCH TYPE IN D1
  8574.     tst.l    d0         TO THE BIG STRING
  8575.     bne.s    do_devices1
  8576.     bsr    copy_bstr
  8577.     move.b    #$20,(a4)+    seperate with spaces
  8578.     tst.l    dvi_Task(a0)
  8579.     bne.s    .H
  8580.     lea    unmounted_tx(pc),a0
  8581.     bsr    copy_name
  8582.     bra.s    .A
  8583. .H    move.b    #"[",(a4)+
  8584.     lea    mounted_tx(pc),a0
  8585.     bsr    copy_name
  8586. .A    move.b    #LF,(a4)+
  8587.     bra.s    .E
  8588. do_devices1
  8589.     move.l    (sp),a2        restart at first devinfo
  8590.     lea    device1_tx(pc),a0    PRINT DEVICES:
  8591.     bsr    copy_name
  8592.     lea    device3_tx(pc),a0
  8593.     bsr    copy_name
  8594. .B    moveq    #dlt_device,d1
  8595.     bsr    find_next_assign    COPY ALL DEVICES THAT MATCH TYPE IN D1
  8596.     tst.l    d0         TO THE BIG STRING
  8597.     bne.s    .A
  8598.     tst.l    dvi_Task(a0)
  8599.     bne.s    .B
  8600.     bsr    copy_bstr
  8601.     move.b    #$20,(a4)+    seperate with spaces
  8602.     move.b    #$20,(a4)+
  8603.     bra.s    .B
  8604. .A    move.b    #LF,(a4)+    linefeed at end
  8605. do_devices2
  8606.     move.l    (sp),a2        restart at first devinfo
  8607.     lea    device1_tx(pc),a0    PRINT DEVICES:
  8608.     bsr    copy_name
  8609.     lea    device2_tx(pc),a0
  8610.     bsr    copy_name
  8611. .B    moveq    #dlt_device,d1
  8612.     bsr    find_next_assign    COPY ALL DEVICES THAT MATCH TYPE IN D1
  8613.     tst.l    d0         TO THE BIG STRING
  8614.     bne.s    .A
  8615.     tst.l    dvi_Task(a0)
  8616.     beq.s    .B
  8617.     bsr    copy_bstr
  8618.     move.b    #$20,(a4)+    seperate with spaces
  8619.     move.b    #$20,(a4)+
  8620.     bra.s    .B
  8621. .A    move.b    #LF,(a4)+    linefeed at end
  8622. do_late
  8623.     move.l    (sp),a2
  8624.     lea    assign_tx(pc),a0    PRINT DIRECTORIES
  8625.     bsr    copy_name
  8626.     moveq    #dlt_late,d1
  8627. .B    bsr    find_next_assign    COPY ALL DEVICES THAT MATCH TYPE IN D1
  8628.     tst.l    d0         TO THE BIG STRING
  8629.     bne.s    .A
  8630.     bsr    copy_bstr
  8631.     move.b    #":",(a4)+
  8632.     move.b    #9,(a4)+    seperate with tab
  8633.     move.b    #"<",(a4)+
  8634.     move.l    dvi_Handler(a0),a0
  8635.     bsr    copy_name
  8636.     move.b    #">",(a4)+
  8637.     move.b    #LF,(a4)+    linefeed at end
  8638.     bra.s    .B
  8639. .A    move.l    (sp),a2
  8640. do_nonbind
  8641.     moveq    #dlt_nonbind,d1
  8642. .B    bsr    find_next_assign    COPY ALL DEVICES THAT MATCH TYPE IN D1
  8643.     tst.l    d0         TO THE BIG STRING
  8644.     bne.s    .A
  8645.     bsr    copy_bstr
  8646.     move.b    #":",(a4)+
  8647.     move.b    #9,(a4)+    seperate with tab
  8648.     move.b    #"[",(a4)+
  8649.     move.l    dvi_Handler(a0),a0
  8650.     bsr    copy_name
  8651.     move.b    #"]",(a4)+
  8652.     move.b    #LF,(a4)+    linefeed at end
  8653.     bra.s    .B
  8654. .A    move.l    (sp),a2
  8655. do_dirs        ;uses top of big mem block (end in a3)
  8656.     move.w    #-1,-(a3)    push negative
  8657. .G    moveq    #dlt_directory,d1
  8658.     bsr    find_next_assign    COPY ALL DEVICES THAT MATCH TYPE IN D1
  8659.     tst.l    d0         TO THE BIG STRING
  8660.     bne.s    .E
  8661.     clr.l    -(a3)        null-end locks
  8662.     cmp.w    #36,kickver(a5)
  8663.     blo.s    .A        OS1.3-: no assign add
  8664.     move.l    dvi_LockList(a0),d0    search locklist (assign add)
  8665.     beq.s    .A
  8666. .B    move.l    d0,a1
  8667.     move.l    4(a1),-(a3)    push locks
  8668.     move.l    (a1),d0
  8669.     bne.s    .B
  8670. .A    move.l    d2,-(a3)    push main lock
  8671.     clr.b    -(a3)        null-end name
  8672.     move.l    dvi_Name(a0),a1
  8673.     add.l    a1,a1
  8674.     add.l    a1,a1
  8675.     moveq    #0,d0
  8676.     move.b    (a1),d0        name-length
  8677.     btst    #0,d0
  8678.     bne.s    .C
  8679.     clr.b    -(a3)        for word-align
  8680. .C    add.l    d0,a1
  8681.     addq.l    #1,a1        a3=end of name
  8682.     bra.s    .D
  8683. .F    move.b    -(a1),-(a3)
  8684. .D    dbra    d0,.F
  8685.     bra.s    .G
  8686.  
  8687. .E    bsr    do_permit
  8688. get_nxt_lock
  8689.     cmp.b    #$ff,(a3)    check for end
  8690.     beq.s    .A
  8691.     move.l    a3,a0
  8692.     bsr    copy_name    copy assign-name
  8693. .B    tst.b    (a3)+        look for end
  8694.     bne.s    .B
  8695.     move.b    #9,(a4)+    copy tab
  8696.     move.l    a3,d0
  8697.     addq.l    #1,d0
  8698.     and.w    #$fffe,d0    word-align
  8699.     move.l    d0,a3
  8700.     move.l    (a3)+,d1    first lock
  8701.     beq.s    .F
  8702.     bra.s    .G
  8703. .C    move.l    (a3)+,d1
  8704.     beq.s    get_nxt_lock
  8705.     move.b    #9,(a4)+    other locks are assign adds
  8706.     move.b    #"+",(a4)+
  8707.     move.b    #" ",(a4)+
  8708. .G    move.l    d1,a0
  8709.     add.l    a0,a0
  8710.     add.l    a0,a0
  8711.     move.l    fl_Volume(a0),a0
  8712.     add.l    a0,a0
  8713.     add.l    a0,a0
  8714.     tst.l    dvi_Task(a0)    check for mounted
  8715.     bne.s    .E
  8716. .F    lea    unmounted_tx(pc),a0
  8717.     bsr    copy_name
  8718.     bra.s    .C
  8719. .E    jsr    _LVODupLock(a6)    copy lock(D1) --> (D0)
  8720.     tst.l    d0
  8721.     beq.s    .F        could not dup lock
  8722.     move.l    a4,a0
  8723.     move.l    a3,-(sp)
  8724.     bsr    eval_full_path    write path to big block
  8725.     move.l    (sp)+,a3
  8726.     jsr    _LVOUnLock(a6)
  8727. .D    tst.b    (a4)+        look for end
  8728.     bne.s    .D
  8729.     move.b    #LF,-1(a4)    overwrite null or tab
  8730.     bra.s    .C
  8731. .A    clr.b    (a4)        null-end
  8732.  
  8733.     move.l    a4,d6
  8734.     subq.l    #1,d6
  8735.     move.l    4(sp),a4
  8736.     bsr    rawh_off
  8737.     bsr    pr_screen
  8738.     move.l    4(sp),a1
  8739.     move.l    #5000,d0
  8740.     bsr    givemem
  8741.     bra.s    asg_fail2
  8742. asg_fail    bsr    do_permit
  8743. asg_fail2    lea    8(sp),sp
  8744.     moveq    #RETURN_OK,d0
  8745.     rts
  8746.  
  8747.  
  8748. get_first_devinfo
  8749.     move.l    dl_Root(a6),a1
  8750.     move.l    rn_Info(a1),a1
  8751.     add.l    a1,a1
  8752.     add.l    a1,a1
  8753.     move.l    di_DevInfo(a1),a2    A2=BPTR to first devinfo
  8754.     rts
  8755.  
  8756. copy_name    move.b    (a0)+,(a4)+
  8757.     bne.s    copy_name
  8758.     lea    -1(a4),a4
  8759.     rts
  8760.  
  8761. **COPY BSTR FROM A1 TO A4, DONT NULL END
  8762. copy_bstr    moveq    #0,d0
  8763.     move.b    (a1)+,d0
  8764.     bra.s    .C
  8765. .B    move.b    (a1)+,(a4)+
  8766. .C    dbra    d0,.B
  8767.     rts
  8768.     
  8769. **ENTRY: D1=type ,A2=Bptr of devinfo, EXIT: A2=Bptr to next ,D0=0 if found
  8770. **EXIT: D2=lock, D1=type, A1 pts to string, A0 pts devinfo struct
  8771. find_next_assign
  8772. .A    add.l    a2,a2    FIND NEXT DEVINFO THAT MATCHES THE TYPE (D1)
  8773.     add.l    a2,a2        A2 pts to first devinfo structure
  8774.     move.l    a2,d0        tst.l    (a2)
  8775.     beq.s    .B
  8776.     move.l    a2,a0
  8777.     move.l    dvi_Name(a2),a1
  8778.     move.l    dvi_Lock(a2),d2
  8779.     move.l    dvi_Type(a2),d0
  8780.     move.l    (a2),a2
  8781.     cmp.l    d0,d1
  8782.     bne.s    .A
  8783.     add.l    a1,a1
  8784.     add.l    a1,a1
  8785.     moveq    #0,d0
  8786.     rts
  8787. .B    moveq    #1,d0
  8788.     rts
  8789.  
  8790. *************************
  8791. *    FAILAT         *
  8792. *************************
  8793. failatz    move.l    parm2(a5),d0
  8794.     beq.s    .A
  8795.     move.l    d0,a1
  8796.     bsr    convert_ASCII_to_num
  8797.     beq    bad_number_error
  8798.     move.l    CLIptr(a5),a0
  8799.     move.l    d0,cli_FailLevel(a0)
  8800.     bra.s    .B
  8801. .A    move.l    #-154,d0
  8802.     bsr    GetMessage
  8803.     move.l    CLIptr(a5),a1
  8804.     lea    cli_FailLevel(a1),a1
  8805.     bsr    new_print
  8806. .B    moveq    #RETURN_OK,d0
  8807.     rts
  8808.  
  8809. *************************
  8810. *    IF         *
  8811. *************************
  8812. ifz    move.b    #$ff,if_flag(a5)
  8813.     move.b    #$ff,if_condition(a5)    set FALSE
  8814.     lea    parm2(a5),a4
  8815.     moveq    #0,d4        not state
  8816. .C    move.l    (a4)+,d0
  8817.     beq    if_fail
  8818.     move.l    d0,a0
  8819.     lea    not_tx(pc),a1
  8820.     bsr    compare_strings
  8821.     bne.s    .B
  8822.     not.b    d4        set D4=FF if not
  8823.     bra    .C
  8824. .B    lea    exists(pc),a1
  8825.     bsr    compare_strings
  8826.     bne.s    try_warn    IF NOT AN EXISTS TYPE COMPARE
  8827.     move.l    (a4)+,d1
  8828.     beq    if_fail
  8829.     moveq    #0,d3        d3=0    doesnt exist
  8830.     moveq    #ACCESS_READ,d2
  8831.     jsr    _LVOLock(a6)
  8832.     tst.l    d0
  8833.     beq.s    save_state
  8834.     move.l    d0,d1
  8835.     jsr    _LVOUnLock(a6)
  8836.     not.b    d3        d3=ff    exists
  8837. save_state
  8838.     not.b    d3        d3=0    true
  8839.     eor.b    d4,d3
  8840.     move.b    d3,if_condition(a5)
  8841.     moveq    #RETURN_OK,D0
  8842.     RTS
  8843. try_warn    move.l    last_failcode(a5),d5
  8844.     moveq    #RETURN_WARN,d6
  8845.     lea    warn_tx(pc),a1    CHECK IF 'IF WARN'
  8846.     bsr    compare_strings
  8847.     bne    try_error
  8848. set_error_state
  8849.     moveq    #0,d3
  8850.     cmp.l    d6,d5
  8851.     bne    save_state
  8852.     not.b    d3
  8853.     bra    save_state
  8854. try_error    lea    error_tx(pc),a1
  8855.     bsr    compare_strings
  8856.     bne    try_fail
  8857.     moveq    #RETURN_ERROR,d6
  8858.     bra    set_error_state
  8859. try_fail    lea    fail_tx(pc),a1
  8860.     bsr    compare_strings
  8861.     bne    if_fail
  8862.     moveq    #RETURN_FAIL,d6
  8863.     bra    set_error_state
  8864. if_fail    not.b    if_flag(a5)    clear it
  8865.     bra    too_less_args
  8866.  
  8867. *************************
  8868. *    ASK         *
  8869. *************************
  8870. askz    bsr    echoz        print the parm same as echo does
  8871. rask    bsr    raw_off
  8872.     move.l    stdin(a5),d1
  8873.     beq.s    .A
  8874.     lea    tempbuf(a5),a4    a4:tempbuf
  8875.     clr.b    (a4)
  8876.     move.l    a4,d2
  8877.     moveq    #120,d3
  8878.     jsr    _LVORead(a6)    read input
  8879.     tst.l    d0
  8880.     bmi.s    .A
  8881.     beq.s    .A
  8882.     move.l    outhandle(a5),d1
  8883.     cmp.l    stdout(a5),d1    output redirected ?
  8884.     beq.s    .C
  8885.     move.l    a4,a0
  8886.     add.l    d0,a0
  8887.     subq.l    #1,a0
  8888.     clr.b    (a0)    Null-End
  8889.     move.l    a4,a1
  8890.     bsr    pr_string    repeat input
  8891.     bra    .A
  8892. .C    or.b    #$20,(a4)
  8893.     moveq    #RETURN_FAIL,d0
  8894.     cmp.b    #'f',(a4)    V2.0
  8895.     beq    .B
  8896.     moveq    #RETURN_ERROR,d0
  8897.     cmp.b    #'e',(a4)    V2.0
  8898.     beq    .B
  8899.     moveq    #RETURN_WARN,d0
  8900.     cmp.b    #'j',(a4)    V2.0
  8901.     beq    .B
  8902.     cmp.b    #'y',(a4)
  8903.     beq    .B
  8904. .A    moveq    #RETURN_OK,D0
  8905. .B    rts
  8906.  
  8907. *************************
  8908. *    WAIT         *
  8909. *************************
  8910. waitz    move.l    parm2(a5),d0
  8911.     beq    too_less_args
  8912.     move.l    d0,a1
  8913.     bsr    convert_ASCII_to_num
  8914.     beq    bad_number_error
  8915.     move.l    d0,d4
  8916.     lsl.l    #2,d4        d4*4
  8917.     add.l    d0,d4        d4:=d0*5 (d4*4+d4)
  8918. .C    bsr    check_c
  8919.     bne.s    .E
  8920.     moveq    #LF,d1        1/5 second
  8921.     jsr    _LVODelay(a6)
  8922.     subq.l    #1,d4
  8923.     bne.s    .C
  8924. .E    moveq    #RETURN_OK,D0
  8925.     RTS
  8926.  
  8927. *************************
  8928. *    QUIT         *
  8929. *************************
  8930. * only returns from script files.
  8931. quitz    tst.b    scflag(a5)
  8932.     bne.s    .A
  8933.     moveq    #RETURN_OK,D0
  8934.     RTS
  8935. .A    move.l    parm2(a5),d0
  8936.     beq    .B
  8937.     move.l    d0,a1
  8938.     bsr    convert_ASCII_to_num
  8939.     bne    .B
  8940.     bsr    bad_number_error
  8941. .B    move.l    d0,-(sp)
  8942.     bsr    kill_script    guarantee that script is dead
  8943.     move.l    (sp)+,d0
  8944.     rts
  8945.     
  8946. *************************
  8947. *    HTYPE         *
  8948. *************************
  8949. htypez    move.l    parm2(a5),d1
  8950.     beq    too_less_args
  8951.     move.l    d1,a0
  8952.     bsr    readfile
  8953.     move.l    d0,mem_addr(a5)
  8954.     move.l    d0,mem_offset_addr(a5)
  8955.     move.l    d1,temp1(a5)
  8956.     add.l    d0,d1
  8957.     move.l    d1,d7        end marker
  8958.     bsr    rawh_off
  8959. .B    bsr    check_c
  8960.     bne    htype_end
  8961.     bsr    show_16_locs
  8962.     cmp.l    mem_addr(a5),d7
  8963.     bhi    .B
  8964. htype_end    move.l    mem_offset_addr(a5),a1
  8965.     move.l    temp1(a5),d0
  8966.     bsr    givemem
  8967.     moveq    #RETURN_OK,D0
  8968.     RTS
  8969.  
  8970. *************************
  8971. *    STRINGS     *
  8972. *************************
  8973. stringsz    move.l    parm2(a5),d0
  8974.     beq    too_less_args
  8975.     moveq    #7,d7        default 7
  8976.     move.l    parm3(a5),d0
  8977.     beq.s    .B
  8978.     move.l    d0,a1
  8979.     bsr    convert_ASCII_to_num
  8980.     beq    bad_number_error
  8981.     
  8982.     move.l    d0,d7        D7=min_string
  8983. .B    move.l    parm2(a5),a0
  8984.     bsr    readfile
  8985.     move.l    d0,a4        A4=addr of file
  8986.     move.l    a4,a3
  8987.     move.l    d1,d6        D6=size of file
  8988.     add.l    d0,d1
  8989.     move.l    d1,d4        D4=max addr
  8990.     movem.l    d4-d7/a3-a4,-(sp)
  8991.     bsr    rawh_off
  8992.     movem.l    (sp)+,d4-d7/a3-a4
  8993. str_next    bsr    check_c
  8994.     bne    kill_string_file
  8995.     moveq    #0,d5        D5=current string size
  8996.     move.l    a3,a2
  8997. valid_ch    cmp.l    a3,d4
  8998.     beq    string_fin
  8999.     move.b    (a3)+,d0
  9000.     cmp.b    #' ',d0
  9001.     blo.s    not_valid_char
  9002.     cmp.b    #$7f,d0
  9003.     bhi.s    not_valid_char
  9004.     addq.l    #1,d5
  9005.     bra    valid_ch
  9006. not_valid_char
  9007.     cmp.l    d7,d5
  9008.     blo    str_next
  9009.     bsr    write_my_string
  9010.     bra    str_next
  9011.  
  9012. string_fin
  9013.     cmp.l    d7,d5
  9014.     blo    kill_string_file
  9015.     bsr    write_my_string
  9016. kill_string_file
  9017.     move.l    a4,a1
  9018.     move.l    d6,d0
  9019.     bsr    givemem
  9020.     moveq    #RETURN_OK,D0
  9021.     RTS
  9022.     
  9023. write_my_string
  9024.     move.l    outhandle(a5),d1
  9025.     beq.s    .A
  9026.     move.l    a2,d2
  9027.     move.l    d5,d3
  9028.     jsr    _LVOWrite(a6)
  9029. .A    bra    pr_lf
  9030.  
  9031. *************************
  9032. *    FILENOTE    *
  9033. *************************
  9034. filenotez bsr    fixpam32        V2.0
  9035.     move.l    a0,d1
  9036.     move.l    a1,d2
  9037.     move.l    a1,a2
  9038.     moveq    #78,d0
  9039. .A    tst.b    (a2)+
  9040.     beq.s    fnok
  9041.     dbra    d0,.A
  9042.     moveq    #RETURN_ERROR,d0    ;more than 80 chars
  9043.     rts
  9044. fnok    jsr    _LVOSetComment(a6)
  9045.     addq.l    #1,d0
  9046.     bne    DOSerr
  9047.     rts
  9048.  
  9049. *************************
  9050. *    SEARCH        *    Searches a string in a file
  9051. *************************
  9052. searchz    bsr    rawh_off        V2.0
  9053.     bsr    fixpam32
  9054.     tst.b    (a1)
  9055.     beq    too_less_args
  9056.     move.l    a1,d7
  9057.     bsr    readfile    get file
  9058.     move.l    d1,d5        push size
  9059.     move.l    d0,d6
  9060.     add.l    d1,d6
  9061.     move.l    d0,a2
  9062.     move.l    d0,a3        a3:start of file
  9063. .A    move.l    d7,a1        d7:search string
  9064.     move.l    d6,a0        d6:end of file
  9065.     bsr    searchSTR    a2:current searchpos
  9066.     cmp.b    #1,d0
  9067.     beq.s    .B
  9068.     move.l    a0,-(sp)
  9069.     move.l    d7,a0
  9070.     moveq    #-1,d4
  9071. .D    addq.l    #1,d4
  9072.     tst.b    (a0)+        length of searchstr.
  9073.     bne.s    .D
  9074.     move.l    a1,d2
  9075.     move.l    a2,d3
  9076.     sub.l    d2,d3
  9077.     beq.s    .C
  9078.     move.l    outhandle(a5),d1
  9079.     jsr    _LVOWrite(a6)    write part before searchstr.
  9080. .C    lea    farb3(pc),a1
  9081.     bsr    pr_string
  9082.     move.l    a2,d2
  9083.     move.l    d4,d3
  9084.     move.l    outhandle(a5),d1
  9085.     jsr    _LVOWrite(a6)    write searchstr.
  9086.     lea    farb1(pc),a1
  9087.     bsr    pr_string
  9088.     move.l    (sp)+,a0
  9089.     move.l    a2,d2
  9090.     add.l    d4,d2
  9091.     move.l    a0,d3
  9092.     sub.l    d2,d3
  9093.     beq.s    .E
  9094.     move.l    outhandle(a5),d1
  9095.     jsr    _LVOWrite(a6)    write part after searchstr.
  9096. .E    bsr    pr_lf
  9097.     addq.l    #1,a2
  9098.     bsr    check_c
  9099.     beq.s    .A
  9100. .B    move.l    d5,d0
  9101.     move.l    a3,a1
  9102.     bsr    givemem        free file
  9103. endse    moveq    #RETURN_OK,d0
  9104.     rts
  9105.  
  9106. * Searches for a string
  9107. * ENTRY:a1 points to the string to search for (ends in NULL)
  9108. *     a2 points to start position, a0 to end of file, a3 to start
  9109. * EXIT: a2  to found-position, a0 to NULL- or LF-end, a1 to LF-start
  9110. *    d0=1 not found, d0= found NULL-ended, d0=10 found LF-ended
  9111. searchSTR
  9112.     movem.l    d1-d7/a3-a5,-(sp)
  9113.     moveq    #"Z",d5
  9114.     moveq    #"A",d6
  9115.     moveq    #" ",d7
  9116.     move.l    a1,a4
  9117.     moveq    #0,d4
  9118. .B    move.b    (a4)+,d0
  9119.     beq.s    .D
  9120.     addq.l    #1,d4        count chars to search for
  9121.     cmp.b    d5,d0
  9122.     bhi.s    .A
  9123.     cmp.b    d6,d0
  9124.     blo.s    .A
  9125.     add.b    d7,d0
  9126.     move.b    d0,-1(a4)    lowercase them
  9127. .A    bra.s    .B
  9128. .D    move.b    (a1),d0
  9129.     cmp.b    ctrl_codes+15(a5),d0
  9130.     bne.s    .C
  9131.     move.b    #LF,(a1)    begins with LineFeed
  9132. .C    move.l    a3,a5
  9133.     move.l    a0,d0        calc length of text
  9134.     sub.l    a2,d0
  9135.     sub.l    d4,d0
  9136.     move.l    d0,d4
  9137.     move.l    d4,d3
  9138.     swap    d3
  9139.     moveq    #0,d0
  9140.     moveq    #0,d2
  9141.     move.b    (a1),d2
  9142.     bra.s    seabeg
  9143. seastrt    move.b    (a2)+,d1
  9144.     cmp.b    d5,d1
  9145.     bhi.s    .E
  9146.     cmp.b    d6,d1
  9147.     blo.s    .E
  9148.     add.b    d7,d1
  9149. .E    cmp.b    d2,d1        compare first char
  9150.     bne.s    seabeg
  9151.  
  9152.     lea    1(a1),a3
  9153.     move.l    a2,a4
  9154. .B    move.b    (a3)+,d0
  9155.     beq.s    seafnd
  9156.     move.b    (a4)+,d1
  9157.     cmp.b    d5,d1
  9158.     bhi.s    .F
  9159.     cmp.b    d6,d1
  9160.     blo.s    .F
  9161.     add.b    d7,d1
  9162. .F    cmp.b    d0,d1        compare other chars
  9163.     beq.s    .B
  9164.  
  9165. seabeg    dbra    d4,seastrt
  9166.     dbra    d3,seastrt
  9167.     bra    seaend
  9168.  
  9169. seafnd    subq.l    #1,a2
  9170.     move.l    a2,a1
  9171. .D    cmp.l    a0,a4
  9172.     bhi    seaend
  9173.     move.b    (a4)+,d1    search end
  9174.     beq.s    .G
  9175.     cmp.b    #LF,d1
  9176.     bne.s    .D
  9177.     cmp.b    #LF,(a1)
  9178.     beq.s    .H
  9179. .F    cmp.l    a5,a1
  9180.     bls    .G
  9181.     move.b    -(a1),d0
  9182.     beq.s    .H
  9183.     cmp.b    #LF,d0        search beginning (if LF)
  9184.     bne.s    .F
  9185. .H    addq.l    #1,a1
  9186. .G    move.b    d1,d2
  9187.     lea    -1(a4),a0
  9188.     move.l    d2,d0
  9189.     movem.l    (sp)+,d1-d7/a3-a5
  9190.     rts
  9191. seaend    moveq    #1,d0
  9192.     movem.l    (sp)+,d1-d7/a3-a5
  9193.     rts
  9194.  
  9195. *****************
  9196. *    FAULT    *
  9197. *****************
  9198. faultz    move.l    parm2(a5),d0            V2.0
  9199.     beq    too_less_args
  9200.     move.l    d0,a1
  9201.     bsr    convert_ASCII_to_num
  9202.     beq    bad_number_error
  9203.     bsr    pr_DOSerr
  9204. .A    moveq    #RETURN_OK,d0
  9205.     rts
  9206.  
  9207. *************************
  9208. *    SETCLOCK    *
  9209. *************************
  9210. setclockz lea    $dc0000,a4    ;clockbase    V2.0
  9211.     move.b    1(a4),d4
  9212.     moveq    #75,d1
  9213.     jsr    _LVODelay(a6)
  9214.     cmp.b    1(a4),d4    ;secs changed ?
  9215.     beq.s    noclk
  9216.     lea    clk_tx(pc),a2
  9217.     move.l    parm2(a5),d0
  9218.     beq.s    .A
  9219.     move.l    d0,a0
  9220.     move.l    a2,a1
  9221.     bsr    CheckOpt
  9222.     beq    clkload
  9223.     lea    8(a2),a1
  9224.     bsr    CheckOpt
  9225.     beq.s    clksave
  9226. .A    move.l    a2,a1
  9227.     bsr    pr_stringlf
  9228. uu    moveq    #RETURN_ERROR,d0
  9229.     rts
  9230. noclk    lea    noclk_tx(pc),a1
  9231.     bsr    pr_stringlf
  9232.     bra.s    uu
  9233.  
  9234. clksave    lea    date_mark(a5),a2
  9235.     move.l    a2,a0
  9236.     bsr    get_time
  9237.     move.l    a2,a1
  9238.     lea    -14(sp),sp
  9239.     lea    (sp),a0
  9240.     bsr    convert_time
  9241.     move.b    61(a4),d0    ;reset clock
  9242.     or.b    #1,d0        ;(don't use bset or bclr !)
  9243.     move.b    d0,61(a4)
  9244.     move.b    #0,57(a4)
  9245.     move.b    #5,61(a4)
  9246.     move.b    #4,61(a4)
  9247.     move.b    53(a4),d0    ;hold clock
  9248.     or.b    #1,d0
  9249.     move.b    d0,53(a4)
  9250. clks    btst    #1,53(a4)
  9251.     bne.s    clks
  9252.     lea    (sp),a0
  9253.     lea    chaotab(pc),a1
  9254.     moveq    #1,d6
  9255.     moveq    #0,d1
  9256.     moveq    #5,d0
  9257. .A    move.b    (a1)+,d1
  9258.     moveq    #0,d2
  9259.     move.w    0(a0,d1),d2
  9260.     divu    #LF,d2
  9261.     swap    d2
  9262.     move.b    d2,0(a4,d6)
  9263.     swap    d2
  9264.     move.b    d2,4(a4,d6)
  9265.     addq.l    #8,d6
  9266.     dbra    d0,.A
  9267.     move.b    53(a4),d0
  9268.     and.b    #$0e,d0
  9269.     move.b    d0,53(a4)    ;run clock
  9270.     lea    14(sp),sp
  9271.     moveq    #RETURN_OK,d0
  9272.     rts
  9273.  
  9274. chaotab    dc.b    10,8,6,0,2,4
  9275.  
  9276. getclk    move.b    0(a4,d6),d1    ;Read realtimeclock
  9277.     move.b    4(a4,d6),d0    ;(adress in a4,offset in d6)
  9278.     addq.l    #8,d6
  9279.     and.w    #$f,d0
  9280.     and.w    #$f,d1
  9281.     mulu    #LF,d0
  9282.     add.w    d1,d0
  9283.     ext.l    d0    ;result
  9284.     rts
  9285.  
  9286.         ;load current time from realtime-clock
  9287. clkload    move.b    53(a4),d0
  9288.     or.b    #1,d0
  9289.     move.b    d0,53(a4)
  9290. clkw    btst    #1,53(a4)
  9291.     bne.s    clkw
  9292.     lea    -6(sp),sp
  9293.     lea    (sp),a3
  9294.     moveq    #5,d2
  9295.     moveq    #1,d6
  9296. .A    bsr    getclk
  9297.     move.b    d0,(a3)+
  9298.     dbra    d2,.A
  9299.     lea    (sp),a3
  9300.     bsr    calcsec        ;how many secs ?
  9301.     move.b    53(a4),d0
  9302.     and.b    #$0e,d0
  9303.     move.b    d0,53(a4)
  9304.     lea    6(sp),sp
  9305.     bsr    tset        ;give it to system
  9306.     moveq    #RETURN_OK,d0
  9307.     rts
  9308.  
  9309. calcsec    moveq    #0,d7        ;a3->points to 6 bytes of date/time
  9310.     moveq    #1,d6                    V2.0
  9311.     move.b    (a3)+,d7    ;sec (collect secs in d7)
  9312.     moveq    #0,d0
  9313.     move.b    (a3)+,d0    ;min
  9314.     mulu    #smin,d0
  9315.     add.l    d0,d7
  9316.     moveq    #0,d0
  9317.     move.b    (a3)+,d0    ;std
  9318.     mulu    #sst,d0
  9319.     add.l    d0,d7
  9320.     moveq    #0,d0
  9321.     move.b    (a3)+,d0    ;tag
  9322.     subq.l    #1,d0
  9323.     move.l    d0,d5        ;collect days in d5
  9324.     moveq    #0,d2
  9325.     move.b    (a3)+,d2    ;monat
  9326.     lea    montab(pc),a0
  9327.     moveq    #0,d3
  9328.     move.b    (a3)+,d3    ;jahr
  9329.     move.l    d3,d0
  9330.     and.w    #3,d0
  9331.     bne.s    nosj
  9332.     move.b    #29,1(a0)    ;change montab
  9333. nosj    subq.l    #2,d2
  9334.     bmi.s    jan
  9335. madd    moveq    #0,d0
  9336.     move.b    0(a0,d2),d0
  9337.     add.w    d0,d5
  9338.     dbra    d2,madd
  9339. jan    cmp.b    #78,d3
  9340.     beq.s    tset
  9341.     subq.l    #1,d3
  9342.     moveq    #0,d1
  9343. jadd    add.w    #tjahr,d5
  9344.     move.l    d3,d0
  9345.     and.w    #3,d0
  9346.     bne.s    nosj2
  9347.     addq.l    #1,d5
  9348. nosj2    cmp.b    #78,d3
  9349.     dbeq    d3,jadd
  9350.     move.b    #28,1(a0)
  9351.     move.l    #stag,d1
  9352.     move.l    d5,d0
  9353.     bsr    mult_32x32
  9354.     move.l    d7,d6        ;d6=secs, d5=days
  9355.     add.l    d0,d7        ;d7=all seconds since 1.1.78
  9356.     rts
  9357.  
  9358. clrio    lea    io_Message(a5),a1    ;initialisiert IO-Request  V2.0
  9359.     move.l    a1,a0
  9360.     moveq    #$2f,d0
  9361. clst3    clr.b    (a0)+
  9362.     dbra    d0,clst3
  9363.     move.b    #5,io_Message+8(a5)
  9364.     move.l    thistask(a5),a0
  9365.     lea    pr_MsgPort(a0),a0
  9366.     move.l    a0,io_Message+14(a5)
  9367.     move.w    #$30,io_Message+18(a5)
  9368.     rts        ;a1:IO-Request a0:Msg-Port
  9369.  
  9370. tset    move.l    4.w,a6        ;set time with timer-device (secs in d7)
  9371.     bsr    clrio                V2.0
  9372.     move.w    #40,io_Message+18(a5)
  9373.     lea    timdev(pc),a0
  9374.     moveq    #1,d0
  9375.     moveq    #0,d1
  9376.     jsr    _LVOOpenDev(a6)
  9377.     tst.l    d0
  9378.     bne    tmfehl
  9379.     lea    io_Message(a5),a1
  9380.     move.w    #11,io_Command(a5)
  9381.     clr.w    io_Flags(a5)
  9382.     move.l    d7,tv_secs(a5)
  9383.     clr.l    tv_micro(a5)
  9384.     jsr    _LVODoIO(a6)
  9385.     tst.l    d0
  9386. ;    bne.s    tmfehl    ;better leave out
  9387.     lea    io_Message(a5),a1
  9388.     clr.l    io_Command(a5)
  9389.     jsr    _LVOCloseDev(a6)
  9390. tmfehl    move.l    dosbase(a5),a6
  9391.     rts
  9392.  
  9393. smin    equ    60
  9394. sst    equ    60*smin
  9395. stag    equ    24*sst
  9396. tjahr    equ    365
  9397.  
  9398.  
  9399. *************************
  9400. *    SHOW        *
  9401. *************************
  9402. soffs    dc.w    378,336,350,364,322,392,532
  9403.  
  9404. showz    bsr    rawh_off            V2.0
  9405.     move.l    parm2(a5),d0
  9406.     beq    sdft
  9407.     move.l    d0,a0
  9408.     move.b    (a0),d1
  9409.     bset    #5,d1
  9410.     cmp.b    #"t",d1
  9411.     beq    shtask
  9412.     cmp.b    #"v",d1
  9413.     beq    shvec
  9414.     lea    styp(pc),a0
  9415.     moveq    #6,d0    ;7 Lists
  9416. .D    cmp.b    0(a0,d0.w),d1
  9417.     dbeq    d0,.D
  9418.     move.w    d0,d7
  9419.     bmi    sdft
  9420.     lea    show_tx(pc),a1
  9421.     cmp.w    #2,d7
  9422.     bhi.s    .C
  9423.     lea    show2_tx(pc),a1
  9424. .C    bsr    pr_stringlf
  9425.     bsr    do_forbid
  9426.     add.w    d0,d0
  9427.     lea    soffs(pc),a0
  9428.     move.w    0(a0,d0.w),d0
  9429.     move.l    4.w,a4
  9430.     move.l    0(a4,d0.w),a1
  9431. ;    move.l    8(a4,d0.w),a2
  9432.     lea    tempbuf(a5),a3
  9433. .A    tst.l    (a1)
  9434.     beq.s    .B
  9435.     move.l    a1,(a3)+
  9436.     move.l    (a1),a1
  9437.     bra.s    .A
  9438. .B    clr.l    (a3)
  9439.     bsr    do_permit
  9440.     lea    tempbuf(a5),a3
  9441. da    tst.l    (a3)
  9442.     beq    sdf
  9443.     move.l    (a3)+,a2
  9444.     move.l    10(a2),-(sp)
  9445.     lea    shform(pc),a0
  9446.     cmp.w    #2,d7
  9447.     bhi.s    .E
  9448.     lea    shform2(pc),a0
  9449.     move.w    22(a2),-(sp)
  9450.     move.w    20(a2),-(sp)
  9451. .E    move.b    9(a2),d0
  9452.     ext.w    d0
  9453.     move.w    d0,-(sp)
  9454.     move.l    a2,-(sp)
  9455.     lea    (sp),a1
  9456.     bsr    new_print
  9457.     lea    10(sp),sp
  9458.     cmp.w    #2,d7
  9459.     bhi.s    da
  9460.     addq.l    #4,sp
  9461.     bra.s    da
  9462. sdft    lea    shuse_tx(pc),a1
  9463.     bsr    pr_stringlf
  9464.     moveq    #RETURN_BAD,d0
  9465.     rts
  9466. sdf    moveq    #RETURN_OK,d0
  9467.     rts
  9468.  
  9469. shtask    lea    tempbuf(a5),a3    enough for 96 tasks
  9470.     move.l    4.w,a6
  9471.     jsr    _LVOForbid(a6)
  9472.     lea    420(a6),a0
  9473.     move.l    (a0),a1
  9474. .A    tst.l    (a1)
  9475.     beq.s    .B
  9476.     move.l    a1,(a3)+
  9477.     move.l    (a1),a1
  9478.     bra.s    .A
  9479. .B    lea    406(a6),a0
  9480.     move.l    (a0),a1
  9481. .C    tst.l    (a1)
  9482.     beq.s    .D
  9483.     move.l    a1,(a3)+
  9484.     move.l    (a1),a1
  9485.     bra.s    .C
  9486. .D    move.l    276(a6),(a3)+
  9487.     clr.l    (a3)
  9488.     jsr    _LVOPermit(a6)
  9489.     move.l    dosbase(a5),a6
  9490.     lea    shta_tx(pc),a1
  9491.     bsr    pr_stringlf
  9492.     lea    tempbuf(a5),a3
  9493. prsht    move.l    (a3)+,a2
  9494.     move.l    10(a2),-(sp)
  9495.     move.l    #$00540061,d0    Task
  9496.     cmp.b    #13,LN_TYPE(a2)
  9497.     bne.s    .C
  9498.     move.l    #$00500072,d0    Process
  9499. .C    move.l    d0,-(sp)
  9500.     move.l    tc_SigWait(a2),-(sp)
  9501.     moveq    #0,d0
  9502.     move.b    tc_State(a2),d0
  9503.     lea    ttyp(pc),a0
  9504.     bra.s    .A
  9505. .B    tst.b    (a0)+
  9506.     bne.s    .B
  9507. .A    dbra    d0,.B
  9508.     move.l    a0,-(sp)
  9509.     move.b    LN_PRI(a2),d0
  9510.     ext.w    d0
  9511.     move.w    d0,-(sp)
  9512.     move.l    a2,-(sp)
  9513.     lea    (sp),a1
  9514.     lea    shtaform(pc),a0
  9515.     bsr    new_print        Print it
  9516.     lea    22(sp),sp
  9517.  
  9518.     cmp.b    #13,LN_TYPE(a2)
  9519.     bne.s    snocli
  9520.     move.l    pr_CLI(a2),d1
  9521.     beq.s    snocli
  9522.     lsl.l    #2,d1    ;cli-process
  9523.     move.l    d1,a4
  9524.     lea    null(pc),a1
  9525.     move.l    a1,-(sp)
  9526.     move.l    pr_COS(a2),d1
  9527.     cmp.l    cli_StandardOutput(a4),d1
  9528.     beq.s    .J
  9529.     lea    bigger(pc),a0
  9530.     move.l    a0,(sp)
  9531. .J    move.l    a1,-(sp)
  9532.     move.l    pr_CIS(a2),d1
  9533.     cmp.l    cli_StandardInput(a4),d1
  9534.     beq.s    .G
  9535.     lea    smaller(pc),a0
  9536.     move.l    a0,(sp)
  9537. .G    move.l    a1,-(sp)
  9538.     move.l    cli_CommandName(a4),d1
  9539.     beq.s    .H
  9540.     lsl.l    #2,d1
  9541.     move.l    d1,a0
  9542.     lea    temp2buf(a5),a1        BSTR !
  9543.     move.l    a1,(sp)
  9544.     moveq    #0,d1
  9545.     move.b    (a0)+,d1
  9546.     bra.s    .E
  9547. .F    move.b    (a0)+,(a1)+
  9548. .E    dbra    d1,.F
  9549.     clr.b    (a1)
  9550. .H    move.l    pr_TaskNum(a2),-(sp)
  9551.     lea    null(pc),a1
  9552.     move.l    a1,-(sp)
  9553.     tst.l    cli_Background(a4)    background ?
  9554.     beq.s    .I
  9555.     lea    backcli(pc),a1
  9556.     move.l    a1,(sp)
  9557. .I    lea    proform(pc),a0
  9558.     lea    (sp),a1
  9559.     bsr    new_print        Print CLI-Add
  9560.     lea    20(sp),sp
  9561. snocli    bsr    pr_lf
  9562.     tst.l    (a3)
  9563.     bne    prsht    ;at least one task
  9564. shtok    moveq    #RETURN_OK,D0
  9565.     rts
  9566.  
  9567. shvec    move.l    4.w,a0
  9568.     move.l    eb_KickCheckSum(a0),-(sp)
  9569.     move.l    eb_ColdCapture(a0),-(sp)
  9570.     move.l    eb_KickTagPtr(a0),-(sp)
  9571.     move.l    eb_CoolCapture(a0),-(sp)
  9572.     move.l    eb_KickMemPtr(a0),-(sp)
  9573.     move.l    eb_WarmCapture(a0),-(sp)
  9574.     lea    (sp),a1
  9575.     lea    vec_line(pc),a0
  9576.     bsr    new_print
  9577.     moveq    #RETURN_ERROR,d0
  9578.     moveq    #5,d1
  9579.     move.l    sp,a0
  9580. .A    tst.l    (a0)+
  9581.     bne.s    .B
  9582.     dbra    d1,.A
  9583.     moveq    #RETURN_OK,d0
  9584. .B    lea    6*4(sp),sp    get rid of trash
  9585.     rts
  9586.  
  9587.  
  9588. *************************
  9589. *    MemClock    *    V2.0
  9590. *************************
  9591.  
  9592. ckstackSIZE    equ    2000
  9593. cktask    equ    0        ;Task-Struct
  9594. ckport    equ    cktask+92    ;MsgPort
  9595. ckstack    equ    ckport+34    ;Stack
  9596. ckustack equ    ckstack+ckstackSIZE
  9597. ckdos    equ    ckustack    ;DOSBase
  9598. ckint    equ    ckdos+4        ;Intuitionbase
  9599. ckitxt    equ    ckint+4        ;IntuiTextStruct
  9600. ckdate    equ    ckitxt+20    ;DateStamp
  9601. ckrawdo    equ    ckdate+12    ;DataStream
  9602. ckcook    equ    ckrawdo+6+8    ;Formatted String
  9603. ckrast    equ    ckcook+40    ;Rastports of all Windows
  9604. cknum    equ    ckrast+20*4    ;Number of Windows
  9605. ckalarm    equ    cknum+4        ;Alarm-Time
  9606. ckpad    equ    ckalarm+8
  9607. cksize    equ    ckpad+2
  9608.  
  9609. mlnode    equ    0        ;Memory-List
  9610. mlnum    equ    mlnode+14
  9611. mladdr    equ    mlnum+2
  9612. mllen    equ    mladdr+4
  9613. mlsize    equ    mllen+4
  9614.  
  9615. memclkz    move.l    parm2(a5),d0
  9616.     beq    too_less_args
  9617.     move.l    d0,a0
  9618.     move.b    (a0),d0
  9619.     bset    #5,d0
  9620.     cmp.b    #"a",d0    ;alarm
  9621.     beq    clkalm
  9622.     bsr    CheckOnOff
  9623.     beq    clkoff
  9624.  
  9625. clkon    move.b    #1,memclk_flag(a5)    switch it on
  9626.     move.l    4.w,a6
  9627.     lea    clktask(pc),a1
  9628.     jsr    _LVOFindTask(a6)
  9629.     move.l    d0,a4
  9630.     tst.l    d0
  9631.     beq.s    .A    ;not already running
  9632.     bsr    winclk
  9633. .B    moveq    #RETURN_OK,d0
  9634.     rts
  9635. .A    move.l    #cksize,d0
  9636.     move.l    #1+1<<16,d1
  9637.     jsr    _LVOAllocMem(a6)
  9638.     tst.l    d0
  9639.     beq.s    .B
  9640.     move.l    d0,a4
  9641.     move.w    #$0104,cktask+8(a4)    ;type/pri
  9642.     lea    clktask(pc),a0
  9643.     move.l    a0,cktask+10(a4)    ;name
  9644.     lea    ckstack(a4),a0
  9645.     lea    ckustack(a4),a1
  9646.     move.l    a1,cktask+54(a4)    ;SPreg
  9647.     move.l    a0,cktask+58(a4)    ;lowerstack
  9648.     move.l    a1,cktask+62(a4)    ;upperstack
  9649.     move.l    a4,ckport+16(a4)    ;sigtask
  9650.     lea    ckport+20+4(a4),a0
  9651.     move.l    a0,ckport+20(a4)
  9652.     lea    ckport+20(a4),a0
  9653.     move.l    a0,ckport+20+8(a4)
  9654.     move.l    #mlsize,d0
  9655.     move.l    #1+1<<16,d1
  9656.     jsr    _LVOAllocMem(a6)
  9657.     tst.l    d0
  9658.     beq.s    .B
  9659.     move.l    d0,a2
  9660.     moveq    #1,d0
  9661.     move.w    d0,mlnum(a2)
  9662.     move.l    a4,mladdr(a2)
  9663.     move.l    #cksize,mllen(a2)
  9664.     lea    mlnode(a2),a0
  9665.     lea    cktask+78(a4),a1
  9666.     move.l    a0,-4(a1)
  9667.     move.l    a0,4(a1)
  9668.     move.l    a1,(a0)
  9669.     move.l    a1,4(a0)
  9670.     move.l    dosbase(a5),ckdos(a4)
  9671.     move.l    intuibase(a5),ckint(a4)
  9672.     bsr    winclk
  9673.     move.l    4.w,a6
  9674.     move.l    a4,a1
  9675.     lea    clkstart(pc),a2
  9676.     moveq    #0,d0
  9677.     move.l    d0,a3
  9678.     jsr    _LVOAddTask(a6)
  9679.     move.l    dosbase(a5),a6
  9680.     moveq    #RETURN_OK,d0
  9681.     rts
  9682.  
  9683. winclk    bsr    findrast    ;check if rastport already exists,
  9684.     tst.w    d1        ;else move rastport in table
  9685.     bpl.s    .C
  9686.     moveq    #19,d1
  9687. .B    tst.l    (a1)+
  9688.     dbeq    d1,.B
  9689.     bne.s    .C
  9690.     move.l    d0,-4(a1)
  9691. .C    rts
  9692.  
  9693. findrast
  9694.     move.l    dosbase(a5),a6
  9695.     bsr    GetWindowPtr    window-ptr to d0
  9696.     beq.s    .B
  9697.     move.l    d0,a0
  9698.     move.l    $32(a0),d0    rastport
  9699.     lea    ckrast(a4),a0
  9700.     move.l    a0,a1
  9701.     moveq    #19,d1
  9702. .A    cmp.l    (a0)+,d0
  9703.     dbeq    d1,.A
  9704. .B    rts
  9705.  
  9706. clkoff    clr.b    memclk_flag(a5)    switch it off
  9707. clkof2    move.l    a4,-(sp)
  9708.     move.l    4.w,a6
  9709.     lea    clktask(pc),a1
  9710.     jsr    _LVOFindTask(a6)
  9711.     move.l    d0,a4
  9712.     tst.l    d0
  9713.     beq.s    .A
  9714.     bsr    findrast
  9715.     tst.w    d1
  9716.     bmi.s    .A
  9717.     moveq    #0,d0
  9718.     move.l    d0,-4(a0)
  9719. .A    move.l    (sp)+,a4
  9720.     move.l    dosbase(a5),a6
  9721.     moveq    #RETURN_OK,d0
  9722.     rts    
  9723.  
  9724. clkalm    move.l    4.w,a6        ;set alarm-time
  9725.     lea    clktask(pc),a1
  9726.     jsr    _LVOFindTask(a6)
  9727.     move.l    dosbase(a5),a6
  9728.     move.l    d0,a4
  9729.     tst.l    d0
  9730.     beq.s    .A
  9731.     tst.l    parm3(a5)
  9732.     bne.s    .B
  9733.     lea    ckalarm(a4),a1
  9734.     bsr    pr_stringlf    show alarm
  9735.     bra.s    .A
  9736. .B    move.l    parm3(a5),a0
  9737.     lea    ckalarm(a4),a1
  9738.     moveq    #7,d0
  9739. .C    move.b    (a0)+,(a1)+    set alarm
  9740.     dbra    d0,.C
  9741. .A    moveq    #RETURN_OK,d0
  9742.     rts    
  9743.  
  9744. clkstart sub.l    a1,a1    ;Here starts the MemClockTaskCode !
  9745.     move.l    4.w,a6
  9746.     jsr    _LVOFindTask(a6)
  9747.     move.l    d0,a5
  9748.     move.l    #$00010100,ckitxt(a5)
  9749. .A    move.l    d5,cknum(a5)    ;teststuff
  9750.     lea    ckdate(a5),a0
  9751.     move.l    a0,d1
  9752.     move.l    ckdos(a5),a6
  9753.     jsr    _LVODateStamp(a6)
  9754.     move.l    ckdate+4(a5),d0        ;mins
  9755.     divu    #60,d0
  9756.     move.w    d0,ckrawdo+8(a5)
  9757.     swap    d0
  9758.     move.w    d0,ckrawdo+10(a5)
  9759.     move.l    ckdate+8(a5),d0        ;secs
  9760.     divu    #50,d0
  9761.     move.w    d0,ckrawdo+12(a5)
  9762.     moveq    #2,d1
  9763.     move.l    4.w,a6
  9764.     jsr    _LVOAvailMem(a6)    ;memory
  9765.     move.l    d0,ckrawdo+4(a5)
  9766.     moveq    #1,d1
  9767.     jsr    _LVOAvailMem(a6)
  9768.     move.l    d0,ckrawdo+0(a5)
  9769.     lea    clkform(pc),a0
  9770.     lea    ckrawdo(a5),a1
  9771.     lea    KPutChar(pc),a2
  9772.     lea    ckcook(a5),a3
  9773.     jsr    _LVORawDoFmt(a6)    ;rawdofmt
  9774.     lea    ckcook+26(a5),a0
  9775.     lea    ckalarm(a5),a1
  9776.     moveq    #7,d0
  9777. .D    move.b    (a0)+,d1
  9778.     cmp.b    (a1)+,d1
  9779.     bne.s    .E
  9780.     dbra    d0,.D
  9781.     move.l    ckint(a5),a6
  9782.     suba.l    a0,a0
  9783.     jsr    _LVODisplayBeep(a6)
  9784. .E    lea    ckcook(a5),a0
  9785.     move.l    a0,ckitxt+12(a5)
  9786.     lea    ckrast(a5),a2
  9787.     moveq    #0,d5
  9788.     moveq    #19,d4
  9789. .B    move.l    (a2)+,a0        ;check all 20 Rastports
  9790.     move.l    a0,d0
  9791.     beq.s    .C
  9792.     addq.l    #1,d5
  9793.     lea    ckitxt(a5),a1
  9794.     moveq    #0,d0
  9795.     moveq    #1,d1
  9796.     move.l    ckint(a5),a6
  9797.     jsr    _LVOPrintIText(a6)
  9798. .C    dbra    d4,.B
  9799.     moveq    #LF,d1
  9800.     move.l    ckdos(a5),a6
  9801.     jsr    _LVODelay(a6)        ;wait 1/5 sec
  9802.     tst.l    d5
  9803.     bne    .A
  9804.     move.l    4.w,a6
  9805.     rts
  9806.  
  9807.  
  9808. *************************
  9809. *    CTRL        *    V2.0
  9810. *************************    set or show ctrl-codes
  9811. ctrlz    move.l    parm2(a5),d0
  9812.     beq.s    .A
  9813.     move.l    d0,a0
  9814.     bsr    return_dash_option
  9815.     cmp.b    #'C',d0        option -COMPLET ?
  9816.     beq.s    ctrlcpl
  9817.     cmp.b    #'R',d0        option -RECOLOR ?
  9818.     beq.s    recolor
  9819.     lea    ctrl_codes(a5),a1
  9820.     moveq    #ctrl_inite-ctrl_init-1,d1
  9821. .B    move.b    (a0)+,d0
  9822.     beq.s    .A
  9823.     and.b    #$3f,d0        set ctrl codes
  9824.     move.b    d0,(a1)+
  9825.     dbra    d1,.B
  9826. .A    lea    ctrl_tx(pc),a1    show ctrl codes
  9827.     bsr    pr_string
  9828.     lea    ctrl_codes(a5),a0
  9829.     lea    tempbuf(a5),a1
  9830.     move.l    a1,a2
  9831.     moveq    #ctrl_inite-ctrl_init-1,d1
  9832. .C    move.b    (a0)+,d0
  9833.     add.b    #$40,d0
  9834.     move.b    d0,(a2)+
  9835.     dbra    d1,.C
  9836.     clr.b    (a2)
  9837.     bsr    pr_stringlf
  9838. ctrlend    moveq    #RETURN_OK,d0
  9839.     rts
  9840.  
  9841. ctrlcpl    lea    ignoreit(a5),a1    set or show exeptions of
  9842.     move.l    parm3(a5),d0    filenamecompletition
  9843.     beq.s    .A
  9844.     move.l    d0,a0
  9845.     moveq    #60-1,d0
  9846. .B    move.b    (a0)+,(a1)+
  9847.     beq.s    ctrlend
  9848.     dbra    d0,.B
  9849.     bra.s    ctrlend
  9850. .A    bsr    pr_stringlf
  9851.     bra.s    ctrlend
  9852.  
  9853. recolor    move.l    parm3(a5),d0
  9854.     beq    too_less_args
  9855.     move.l    d0,a3
  9856.     lea    start(pc),a0
  9857.     lea    recol1(pc),a1
  9858.     lea    recol2(pc),a2
  9859.     moveq    #0,d2
  9860.     moveq    #(recol2-recol1)/2-1,d0
  9861. .A    move.w    (a1)+,d1
  9862.     move.b    (a2)+,d2
  9863.     move.b    0(a3,d2.w),d3
  9864.     move.b    d3,0(a0,d1.w)
  9865.     dbra    d0,.A
  9866.     bra    clsz
  9867.  
  9868. *************************
  9869. *    Locate        *    V2.0
  9870. ************************* Show the Path and Filename of a Lock-Struct
  9871. locatez            ;or lock object or delete lock
  9872.     bsr    fixpam32
  9873.     move.l    a0,a3
  9874.     move.l    a1,a2
  9875.     move.l    a0,a1    ;parm2
  9876.     moveq    #0,d7
  9877.     bsr    return_dash_option
  9878.     cmp.b    #"C",d0
  9879.     bne.s    .F
  9880.     moveq    #-1,d7        delete lock after showing
  9881.     move.l    a2,a1
  9882. .F    bsr    convert_ASCII_to_num
  9883.     bne.s    .D
  9884.     moveq    #ACCESS_READ,d2
  9885.     move.l    a2,a1    ;parm3    create lock
  9886.     bsr    convert_ASCII_to_num
  9887.     beq.s    .E
  9888.     move.l    d0,d2
  9889. .E    move.l    a3,d1    ;parm2
  9890.     jsr    _LVOLock(a6)
  9891.     tst.l    d0
  9892.     beq    .A
  9893. .D    move.l    d0,a2        write out name
  9894.     move.l    d0,d6
  9895.     add.l    a2,a2
  9896.     add.l    a2,a2
  9897.     moveq    #ACCESS_WRITE,d1
  9898.     cmp.l    fl_Access(a2),d1    what kind of lock
  9899.     bne.s    .B
  9900.     lea    lockwrite(pc),a1
  9901.     bra.s    .C
  9902. .B    subq.l    #1,d1
  9903.     cmp.l    fl_Access(a2),d1
  9904.     bne.s    .A
  9905.     lea    lockread(pc),a1
  9906. .C    lea    -16(sp),sp
  9907.     move.l    a1,(sp)
  9908.     move.l    fl_Link(a2),12(sp)
  9909.     move.l    d6,8(sp)
  9910.     move.l    d0,d1
  9911.     jsr    _LVODupLock(a6)
  9912.     lea    tempbuf(a5),a0
  9913.     move.l    a0,4(sp)
  9914.     bsr    eval_full_path    evaluate the full name
  9915.     jsr    _LVOUnLock(a6)
  9916.     move.l    sp,a1
  9917.     lea    locktext(pc),a0
  9918.     bsr    new_print
  9919.     lea    16(sp),sp
  9920.     tst.l    d7
  9921.     beq.s    .G
  9922.     move.l    d6,d1
  9923.     jsr    _LVOUnLock(a6)
  9924.     lea    deleteOK(pc),a1
  9925.     bsr    pr_string
  9926. .G    moveq    #RETURN_OK,d0
  9927.     rts
  9928. .A    lea    lockntx(pc),a1
  9929.     bsr    pr_stringlf
  9930. lkerr    moveq    #RETURN_ERROR,d0
  9931.     rts
  9932.  
  9933. *************************
  9934. *    NewCLI        *    V2.0
  9935. *************************
  9936. newcliz    lea    ZShellName(pc),a0
  9937.     move.l    a0,d1        process-name
  9938.     moveq    #0,d2        priority
  9939.     lea    start-4(pc),a0
  9940.     move.l    a0,d3        
  9941.     lsr.l    #2,d3        seglist
  9942.     move.l    #4000,d4    stacksize
  9943.     jsr    _LVOCreateProc(a6)
  9944.     tst.l    d0
  9945.     beq.s    lkerr
  9946.     move.l    d0,a4        a4:new process
  9947.     moveq    #$24,d0
  9948.     move.l    #MEMF_CLEAR+1,d1    memory for Message
  9949.     bsr    iwantmem
  9950.     beq.s    lkerr
  9951.     move.l    d0,a1        a1,a3:message
  9952.     move.l    a1,a3
  9953.     move.b    #5,LN_TYPE(a1)
  9954.     move.l    thistask(a5),a0
  9955.     lea    pr_MsgPort(a0),a2    a2:msgport of this task
  9956.     move.l    a2,mn_ReplyPort(a1)
  9957.     move.w    #$24,mn_Length(a1)
  9958.     move.l    a5,sm_NumArgs(a1)
  9959.     move.l    a4,a0
  9960.     move.l    4.w,a6
  9961.     jsr    _LVOPutMsg(a6)
  9962. .A    move.l    a2,a0
  9963.     jsr    _LVOWaitPort(a6)
  9964.     move.l    a2,a0
  9965.     jsr    _LVOGetMsg(a6)
  9966.     cmp.l    a3,d0
  9967.     bne    .A
  9968. ;    move.l    dosbase(a5),a6
  9969.     move.l    d0,a1
  9970.     moveq    #$24,d0
  9971.     bsr    givemem
  9972.     moveq    #RETURN_OK,d0
  9973.     rts
  9974.  
  9975. *************************
  9976. *    RUN        *    V2.2
  9977. *************************
  9978. runz    clr.l    parm3(a5)
  9979.     bsr    ConvertSemi
  9980.     move.l    parm2(a5),a0
  9981.     bsr    return_dash_option
  9982.     lea    CLIbuf(a5),a1
  9983.     cmp.b    #'C',d0
  9984.     bne.s    .C
  9985.     lea    runnil(pc),a0    redir in/out to nil
  9986.     move.l    a0,parm3(a5)
  9987.     clr.l    parm4(a5)
  9988.     addq.l    #3,a1
  9989. .C    lea    tempbuf(a5),a0
  9990.     move.l    a0,parm2(a5)
  9991.     move.w    #'-c',(a0)+
  9992. .A    move.b    (a1)+,(a0)+    copy CLIbuf
  9993.     bne.s    .A
  9994.     subq.l    #1,a0
  9995.     lea    runit(pc),a1
  9996. .B    move.b    (a1)+,(a0)+    copy appendix
  9997.     bne.s    .B
  9998.     bra    newcliz
  9999.  
  10000. *************************
  10001. *    TaskPri        *    V2.0
  10002. *************************
  10003. taskpriz bsr    fixpam32
  10004.     move.l    a1,a2
  10005.     move.l    a0,a1
  10006.     tst.b    (a1)
  10007.     beq    too_less_args
  10008.     bsr    convert_ASCII_to_num
  10009.     beq    bad_number_error
  10010.     move.l    d0,d7
  10011.     bsr    findtsk
  10012.     beq    pr_notfound
  10013.     move.l    a0,a1
  10014.     move.b    d7,d0
  10015.     move.l    4.w,a6
  10016.     jsr    _LVOSetTaskPri(a6)
  10017. tskok    move.l    dosbase(a5),a6
  10018.     moveq    #RETURN_OK,d0
  10019.     rts
  10020.  
  10021. * Find Task given in a2 (ptr,string,cli-number,null)
  10022. * RETURN: d0,a0 address (0 if not found)
  10023. findtsk    move.l    a2,a1
  10024.     moveq    #0,d0
  10025.     tst.b    (a1)
  10026.     beq.s    .E
  10027.     bsr    convert_ASCII_to_num
  10028.     beq.s    .C
  10029. .E    cmp.l    #20,d0
  10030.     bhi.s    .A        is address
  10031.     move.l    d0,a1
  10032.     tst.l    d0        0 means own task
  10033.     beq.s    .D
  10034.     lsl.l    #2,d0        is a cli-number
  10035.     move.l    dl_Root(a6),a0
  10036.     move.l    (a0),a0
  10037.     add.l    a0,a0
  10038.     add.l    a0,a0
  10039.     add.l    d0,a0
  10040.     move.l    (a0),d0
  10041.     beq.s    .B
  10042.     sub.l    #pr_MsgPort,d0
  10043.     bra.s    .A
  10044. .C    move.l    a2,a1
  10045. .D    move.l    4.w,a6
  10046.     jsr    _LVOFindTask(a6)    search name
  10047.     move.l    dosbase(a5),a6
  10048. .A    tst.l    d0
  10049.     beq.s    .B
  10050.     move.l    d0,a0
  10051.     cmp.b    #01,LN_TYPE(a0)    is it a TASK-struct ?
  10052.     beq.s    .B
  10053.     cmp.b    #13,LN_TYPE(a0)    is it a PROCESS-struct ?
  10054.     beq.s    .B
  10055.     moveq    #0,d0
  10056. .B    tst.l    d0
  10057.     rts
  10058.  
  10059. *************************
  10060. *    Break        *    V2.0
  10061. *************************
  10062. breakz    bsr    fixpam32
  10063.     move.l    a0,a2
  10064.     move.l    a1,a3
  10065.     tst.b    (a2)
  10066.     beq    too_less_args
  10067.     bsr    findtsk
  10068.     beq    pr_notfound
  10069.     move.l    a3,a1
  10070.     move.l    a0,a2
  10071.     tst.b    (a1)
  10072.     beq.s    .B
  10073.     bsr    convert_ASCII_to_num
  10074.     bne.s    .C
  10075.     moveq    #RETURN_ERROR,d0
  10076.     move.b    (a3),d1
  10077.     bclr    #5,d1
  10078.     cmp.b    #"C",d1
  10079.     blo.s    .A
  10080.     cmp.b    #"F",d1
  10081.     bhi.s    .A
  10082.     sub.b    #55,d1
  10083.     moveq    #0,d0
  10084.     bset    d1,d0
  10085.     bra.s    .C
  10086. .B    move.l    tc_SigWait(a2),d0
  10087. .C    move.l    a2,a1
  10088.     move.l    4.w,a6
  10089.     jsr    _LVOSignal(a6)    set signals given in mask
  10090.     move.l    dosbase(a5),a6
  10091.     moveq    #RETURN_OK,d0
  10092. .A    rts
  10093.  
  10094. *************************
  10095. *    PutMsg        *    V2.0
  10096. *************************
  10097. putmsgz    move.l    parm2(a5),d7
  10098.     beq    printa5
  10099.     move.l    d7,a1
  10100.     bsr    convert_ASCII_to_num
  10101.     bne.s    .D
  10102.     move.l    d7,a1
  10103.     move.l    4.w,a6
  10104.     jsr    _LVOFindPort(a6)    search name
  10105.     move.l    dosbase(a5),a6
  10106.     tst.l    d0
  10107.     beq.s    .B
  10108.     move.l    d0,a0
  10109.     bra.s    .E
  10110. .D    move.l    d0,a0
  10111.     cmp.l    #20,d0
  10112.     bls.s    .B
  10113.     cmp.b    #04,LN_TYPE(a0)    is it a MSGPORT-struct ?
  10114.     beq.s    .E
  10115. .B    move.l    d7,a2
  10116.     bsr    findtsk        search task
  10117.     bne.s    .C
  10118. .A    bra    pr_notfound
  10119. .C    cmp.b    #13,LN_TYPE(a0)    is it a PROCESS-struct ?
  10120.     bne.s    .A
  10121.     lea    pr_MsgPort(a0),a0
  10122. .E    bsr    clearArgs
  10123.     move.l    thistask(a5),a2
  10124.     lea    pr_MsgPort(a2),a2
  10125.     move.l    a2,sp_reply(a5)
  10126.     move.b    #5,LN_TYPE+sp_node(a5)
  10127.     lea    parm3(a5),a2
  10128.     lea    sp_link(a5),a3
  10129.     moveq    #mn_Size,d2
  10130. .G    move.l    (a2)+,d3
  10131.     beq.s    .F
  10132.     move.l    d3,a1
  10133.     bsr    convert_ASCII_to_num
  10134.     bne.s    .H
  10135.     move.l    d3,d0
  10136. .H    move.l    d0,(a3)+
  10137.     addq.w    #4,d2
  10138.     bra.s    .G
  10139. .F    move.w    d2,sp_length(a5)
  10140.     move.l    sp_link(a5),a1
  10141.     move.b    (a1),d0
  10142.     cmp.b    ctrl_codes+15(a5),d0
  10143.     bne.s    .I
  10144.     lea    sp_link(a5),a1        for DOSpackets
  10145.     move.l    a1,LN_NAME+sp_node(a5)
  10146.     lea    sp_node(a5),a1
  10147.     move.l    a1,sp_link(a5)
  10148.     move.l    sp_reply(a5),sp_port(a5)
  10149. .I    lea    msendtx(pc),a1
  10150.     bsr    pr_stringlf
  10151.     lea    sp_node(a5),a1        message
  10152.     move.l    4.w,a6
  10153.     jsr    _LVOPutMsg(a6)
  10154.     move.l    dosbase(a5),a6
  10155.     clr.l    parm2(a5)
  10156.     bra.s    getmsg1
  10157.  
  10158. *************************
  10159. *    GetMsg        *    V2.0
  10160. *************************
  10161. getmsgz    moveq    #0,d7
  10162.     moveq    #0,d6
  10163.     move.l    parm2(a5),d2
  10164.     beq.s    getmsg1
  10165.     move.l    d2,a1
  10166.     move.l    4.w,a6
  10167.     jsr    _LVOFindPort(a6)    does it already exist ?
  10168.     tst.l    d0
  10169.     bne.s    getmsg1
  10170.     move.l    thistask(a5),a1
  10171.     lea    pr_MsgPort(a1),a1
  10172.     move.l    d2,LN_NAME(a1)
  10173.     jsr    _LVOAddPort(a6)
  10174.     moveq    #1,d6
  10175. getmsg1    move.l    thistask(a5),a2
  10176.     lea    pr_MsgPort(a2),a2
  10177.     move.l    4.w,a6
  10178.     move.l    a2,a0
  10179.     jsr    _LVOGetMsg(a6)
  10180.     tst.l    d0
  10181.     bne.s    .A
  10182.     moveq    #0,d2
  10183.     move.b    MP_SIGBIT(a2),d1
  10184.     bset    d1,d2
  10185.     bset    #SIGBREAKB_CTRL_C,d2
  10186.     move.l    d2,d1
  10187. ;    moveq    #0,d0
  10188.     jsr    _LVOSetSignal(a6)    clear signals
  10189.     move.l    d2,d0
  10190.     jsr    _LVOWait(a6)    wait for msgport or ctrl-c
  10191.     move.l    a2,a0
  10192.     jsr    _LVOGetMsg(a6)
  10193. .A    move.l    dosbase(a5),a6
  10194.     tst.l    d0
  10195.     beq    msgfail
  10196.     move.l    d0,a2
  10197.     move.w    mn_Length(a2),d2
  10198.     move.w    d2,-(sp)
  10199.     move.l    a2,-(sp)
  10200.     lea    msgtx(pc),a0
  10201.     move.l    sp,a1
  10202.     bsr    new_print
  10203.     addq.l    #6,sp
  10204.     sub.w    #mn_Size,d2
  10205.     lsr.w    #2,d2
  10206.     lea    mn_Size(a2),a3
  10207.     bra.s    .D
  10208. .C    move.l    (a3)+,d0
  10209.     cmp.l    #$dfe000,d0
  10210.     bhs.s    .E
  10211.     cmp.l    #$a00000,d0
  10212.     blo.s    .F
  10213.     cmp.l    #$c00000,d0
  10214.     blo.s    .E
  10215. .F    move.l    d0,a0
  10216.     moveq    #79,d1
  10217. .H    move.b    (a0)+,d3
  10218.     beq.s    .G
  10219.     cmp.b    #" ",d3
  10220.     blo.s    .E
  10221.     cmp.b    #"~",d3
  10222.     bhi.s    .E
  10223.     dbra    d1,.H
  10224.     bra.s    .E
  10225. .G    cmp.w    #76,d1
  10226.     bhs.s    .E
  10227.     bsr    printADR
  10228.     bsr    pr_space
  10229.     move.l    d0,a1
  10230.     bsr    pr_stringlf
  10231.     bra.s    .D
  10232. .E    bsr    printADR
  10233.     bsr    pr_lf
  10234. .D    dbra    d2,.C
  10235.     tst.l    d7
  10236.     bne.s    .B
  10237.     tst.l    d6
  10238.     beq.s    .I
  10239.     move.l    thistask(a5),a1
  10240.     lea    pr_MsgPort(a1),a1
  10241.     move.l    4.w,a6
  10242.     jsr    _LVORemPort(a6)
  10243.     move.l    dosbase(a5),a6
  10244. .I    lea    replytx(pc),a1
  10245.     bsr    pr_string
  10246.     bsr    rask
  10247.     move.l    d0,d2
  10248.     beq.s    .B
  10249.     move.l    4.w,a6
  10250.     move.l    a2,a1
  10251.     jsr    _LVOReplyMsg(a6)
  10252.     move.l    dosbase(a5),a6
  10253.     cmp.b    #RETURN_ERROR,d2
  10254.     beq    getmsg1
  10255. .B    moveq    #RETURN_OK,d0
  10256.     rts
  10257. printa5    move.l    a5,-(sp)
  10258.     move.l    sp,a1
  10259.     lea    pra5tx(pc),a0
  10260.     bsr    new_print
  10261.     addq.l    #4,sp
  10262.     bsr    DisplayBeep
  10263. msgfail    moveq    #RETURN_ERROR,d0
  10264.     rts
  10265.  
  10266. *************************
  10267. *    Border        *    V2.0
  10268. *************************
  10269. wd_BorderLeft    equ    54
  10270. wd_Flags    equ    24
  10271.  
  10272. borderz    move.l    parm2(a5),a0
  10273.     bsr    CheckOnOff
  10274.     move.l    d0,-(sp)
  10275.     bsr    GetWindowPtr
  10276.     beq    nosiz
  10277.     move.l    d0,a0
  10278.     move.l    a0,a4        this window
  10279.     move.l    intuibase(a5),a6
  10280.     moveq    #0,d0
  10281.     jsr    _LVOLockIBase(a6)
  10282.     move.l    d0,d7
  10283.     move.l    (sp)+,d0
  10284.     beq    bordoff
  10285.  
  10286. bordon    tst.l    bordersize(a5)
  10287.     beq.s    borne
  10288.     bclr    #11,wd_Flags+2(a4)    unset noborder
  10289.     move.l    bordersize(a5),wd_BorderLeft(a4)
  10290.     bra.s    borjo
  10291.  
  10292. bordoff    tst.l    wd_BorderLeft(a4)
  10293.     beq.s    borjo
  10294.     bset    #11,wd_Flags+2(a4)    set noborder-window
  10295.     move.l    wd_BorderLeft(a4),bordersize(a5)
  10296.     clr.l    wd_BorderLeft(a4)
  10297. borjo    moveq    #$00,d0        null resize
  10298.     moveq    #$00,d1
  10299.     move.l    a4,a0
  10300.     jsr    _LVOSizeWindow(a6)
  10301.     move.l    a4,a0
  10302.     jsr    _LVORefreshWindowFrame(a6)    redraw
  10303. borne    move.l    d7,a0
  10304.     jsr    _LVOUnlockIBase(a6)
  10305.     move.l    parm3(a5),d0
  10306.     beq.s    nosiz
  10307.     move.l    d0,a1
  10308.     bsr    convert_ASCII_to_num
  10309.     tst.l    d1
  10310.     beq.s    nosiz
  10311.                 ;resize window to fill screen
  10312.     move.l    $2e(a4),a1    points to screen
  10313.     move.l    d0,d4    width of menubar
  10314.     bpl.s    .A
  10315.     moveq    #0,d4
  10316.     move.b    30(a1),d4
  10317.     add.b    31(a1),d4
  10318. .A    moveq    #-1,d2
  10319.     move.l    12(a1),d3
  10320.     sub.w    10(a4),d3
  10321.     sub.w    d4,d3
  10322.     move.w    d3,d1
  10323.     bpl.s    bklein
  10324.     moveq    #0,d2
  10325.     moveq    #0,d0
  10326.     move.l    a4,a0
  10327.     jsr    _LVOSizeWindow(a6)
  10328. bklein    moveq    #0,d0
  10329.     sub.w    4(a4),d0
  10330.     move.l    d4,d1
  10331.     sub.w    6(a4),d1
  10332.     move.l    a4,a0
  10333.     jsr    _LVOMoveWindow(a6)
  10334.     moveq    #0,d1
  10335.     tst.b    d2
  10336.     beq.s    bgross
  10337.     move.w    d3,d1
  10338. bgross    swap    d3
  10339.     sub.w    8(a4),d3
  10340.     move.w    d3,d0
  10341.     move.l    a4,a0
  10342.     jsr    _LVOSizeWindow(a6)
  10343.     jsr    _LVORethinkDisplay(a6)
  10344.     
  10345. nosiz    move.l    dosbase(a5),a6
  10346.     moveq    #10,d1        wait more than 1/10 sec
  10347.     jsr    _LVODelay(a6)
  10348.     moveq    #RETURN_OK,d0
  10349.     rts
  10350.  
  10351. *************************
  10352. *    Review        *    V2.1
  10353. *************************
  10354. reviewz    move.l    parm2(a5),d0
  10355.     beq.s    ShowReview
  10356.     move.l    d0,a1
  10357.     move.l    d0,a2
  10358.     bsr    convert_ASCII_to_num
  10359.     bne.s    MakeReview
  10360.     or.b    #$20,(a2)
  10361.     cmp.b    #"c",(a2)
  10362.     beq.s    ClearReview
  10363.     cmp.b    #"s",(a2)
  10364.     bne.s    ShowReview
  10365.     move.l    parm3(a5),d0        Save review-buffer
  10366.     beq    too_less_args
  10367.     tst    ReviewSize(a5)
  10368.     beq.s    ShowReview
  10369.     move.l    d0,a3
  10370.     bra    viewbuffer
  10371.  
  10372. ShowReview
  10373.     move.l    ReviewSize(a5),d0    Show review-info
  10374.     bsr    print10
  10375.     lea    view1_tx(pc),a1
  10376.     bsr    pr_string
  10377.     moveq    #RETURN_OK,d0
  10378.     rts
  10379.  
  10380. ClearReview
  10381.     move.l    ReviewMem(a5),a0
  10382.     move.l    ReviewSize(a5),d0
  10383.     move.l    d0,d1
  10384.     swap    d1
  10385.     bra.s    .D
  10386. .E    move.b    #" ",(a0)+    Fill with spaces
  10387. .D    dbra    d0,.E
  10388.     dbra    d1,.E
  10389.     move.b    #LF,-1(a0)    Last char is LF
  10390.     clr.l    ReviewPtr(a5)
  10391.     moveq    #RETURN_OK,d0
  10392.     rts
  10393.  
  10394. MakeReview
  10395.     tst.l    d0            Add review-buffer
  10396.     beq    reviewend
  10397.     tst.l    ReviewSize(a5)
  10398.     beq.s    .F
  10399.     move.l    d0,-(sp)
  10400.     bsr    reviewend
  10401.     move.l    (sp)+,d0
  10402. .F    move.l    d0,d2
  10403.     moveq    #1,d1
  10404.     bsr    iwantmem
  10405.     beq    ShowReview
  10406.     move.l    d0,ReviewMem(a5)
  10407.     move.l    d2,ReviewSize(a5)
  10408.     bsr    ClearReview
  10409.     clr.b    noreview_flag(a5)
  10410.     lea    RHa3(pc),a3        Look for a5-Table
  10411.     tst.l    (a3)
  10412.     bne.s    entryA5
  10413.     moveq    #80,d0
  10414.     move.l    #1+1<<16,d1        "memf_public" & clear it
  10415.     bsr    iwantmem
  10416.     beq    reviewend
  10417.     move.l    d0,(a3)
  10418. APatch    moveq    #_LVOWrite,d2        Add review-patch to DOS Write
  10419.     move.w    #$4ef9,d3
  10420.     move.l    a6,a2
  10421.     add.l    d2,a2
  10422.     moveq    #0,d1
  10423.     cmp.w    (a2),d3
  10424.     bne.s    .B
  10425.     move.l    2(a2),a0
  10426.     lea    RCode(pc),a1
  10427.     cmp.l    a1,a0
  10428.     beq.s    entryA5
  10429.     moveq    #-1,d1
  10430.     bra.s    .C
  10431. .B    cmp.w    #$6000,2(a2)
  10432.     bne.s    reviewend
  10433. .C    movem.l    d0-d1/a0-a1,-(sp)
  10434.     bsr    do_forbid
  10435.     movem.l    (sp)+,d0-d1/a0-a1
  10436.     lea    RHa1(pc),a1
  10437.     move.w    (a2),(a1)
  10438.     move.l    2(a2),2(a1)
  10439.     tst.w    d1
  10440.     bne.s    .D
  10441.     lea    4(a2),a0
  10442.     move.w    (a0),d0
  10443.     ext.l    d0
  10444.     add.l    d0,a0
  10445.     move.l    a0,4(a1)
  10446.     move.w    d3,2(a1)
  10447. .D    lea    RCode(pc),a0
  10448.     move.w    d3,(a2)
  10449.     move.l    a0,2(a2)
  10450.     bsr    do_permit
  10451. entryA5    move.l    (a3),a3            Add a5-table entry
  10452.     moveq    #20-1,d0
  10453. .F    tst.l    (a3)+
  10454.     beq.s    .G
  10455.     dbra    d0,.F
  10456.     bra    reviewend
  10457. .G    move.l    a5,-4(a3)
  10458.     bra    reviewOK
  10459.  
  10460. reviewend        ;Remove review-buffer
  10461.     move.l    RHa3(pc),d0        Remove a5-table entry
  10462.     beq.s    remmem2
  10463.     move.l    d0,a0
  10464.     move.l    a0,a1
  10465.     move.l    a0,a2
  10466.     moveq    #20-1,d0
  10467. .A    cmp.l    (a0)+,a5
  10468.     beq.s    .B
  10469.     dbra    d0,.A
  10470.     bra.s    .D
  10471. .B    clr.l    -4(a0)
  10472. .D    moveq    #20-1,d0    look for other entries
  10473. .C    tst.l    (a2)+
  10474.     bne.s    remmem2
  10475.     dbra    d0,.C
  10476.     bsr    do_forbid
  10477.     lea    RHa3(pc),a0
  10478.     clr.l    (a0)
  10479.     moveq    #80,d0        last entry
  10480.     bsr    givemem
  10481.     moveq    #_LVOWrite,d0        Remove DOS Write Patch
  10482.     move.l    a6,a3
  10483.     add.l    d0,a3
  10484.     move.l    2(a3),a0
  10485.     lea    RCode(pc),a1
  10486.     cmp.l    a0,a1
  10487.     bne.s    remmem
  10488.     lea    RHa1(pc),a1
  10489.     move.w    (a1),(a3)
  10490.     move.l    2(a1),2(a3)
  10491.     cmp.w    #$4ef9,(a1)
  10492.     beq.s    remmem
  10493.     move.w    #$6000,2(a3)
  10494.     lea    4(a3),a2
  10495.     move.l    4(a1),d0
  10496.     sub.l    a2,d0
  10497.     move.w    d0,(a2)
  10498. remmem    bsr    do_permit
  10499. remmem2    move.l    ReviewSize(a5),d0    Remove buffer-memory
  10500.     beq.s    reviewOK
  10501.     move.l    ReviewMem(a5),a1
  10502.     bsr    givemem
  10503.     clr.l    ReviewSize(a5)
  10504. reviewOK
  10505.     moveq    #RETURN_OK,d0
  10506.     rts
  10507.  
  10508. viewbuffer        ;Show the review-buffer using more
  10509.     move.l    ReviewMem(a5),a2
  10510.     move.l    ReviewPtr(a5),d3
  10511.     move.l    ReviewSize(a5),d2
  10512.     bne.s    viewhist
  10513.     rts
  10514. viewhist    ;;Show a circular buffer using more
  10515.     move.l    d2,d4
  10516.     move.l    MPipePtr(a5),d1
  10517.     beq.s    .A
  10518.     move.l    d3,d0    for redirecting to more
  10519.     move.l    d1,d3
  10520.     sub.l    d0,d1
  10521.     bpl.s    .C
  10522.     add.l    d2,d1
  10523.     bra.s    .C
  10524. .A
  10525. .I    move.b    0(a2,d3.l),d0
  10526.     addq.l    #1,d3
  10527.     cmp.l    d3,d2
  10528.     bhi.s    .B
  10529.     clr.l    d3
  10530. .B    addq.l    #1,d1
  10531.     cmp.b    #LF,d0
  10532.     beq.s    .C
  10533.     cmp.b    #12,d0
  10534.     bne.s    .I
  10535. .C    sub.l    d1,d2
  10536.     move.l    d2,d0
  10537.     beq.s    reviewOK
  10538.     moveq    #1,d1
  10539.     bsr    iwantmem
  10540.     beq.s    reviewOK
  10541.     move.l    d0,a0
  10542.     move.l    a0,a1
  10543.     move.l    d4,d1
  10544.     move.l    d2,d4
  10545.     bra.s    .E
  10546. .D    move.b    0(a2,d3.l),d0
  10547.     cmp.b    #12,d0
  10548.     bne.s    .G
  10549.     move.b    #LF,d0
  10550. .G    cmp.b    #"c",d0
  10551.     bne.s    .H
  10552.     cmp.b    #27,-1(a0)
  10553.     bne.s    .H
  10554.     move.b    #" ",-1(a0)
  10555.     move.b    #LF,d0
  10556. .H    move.b    d0,(a0)+
  10557.     addq.l    #1,d3
  10558.     cmp.l    d3,d1
  10559.     bhi.s    .E
  10560.     clr.l    d3
  10561. .E    dbra    d2,.D
  10562.     move.l    a3,d0
  10563.     bne.s    viewwrite
  10564.     move.l    a1,d0
  10565.     move.l    d4,d1
  10566.     moveq    #-1,d2
  10567.     tst.l    MPipePtr(a5)
  10568.     beq.s    .F
  10569.     moveq    #0,d2
  10570. .F    moveq    #0,d4
  10571.     bra    ViewMore
  10572. viewwrite        ;write buffer to file
  10573.     move.l    a1,a2
  10574.     move.l    a3,d1
  10575.     move.l    #MODE_NEWFILE,d2
  10576.     jsr    _LVOOpen(a6)
  10577.     tst.l    d0
  10578.     beq.s    .A
  10579.     move.l    d0,a3
  10580.     move.l    a3,d1
  10581.     move.l    a2,d2
  10582.     move.l    d4,d3
  10583.     move.l    d3,-(sp)
  10584.     jsr    _LVOWrite(a6)
  10585.     move.l    (sp)+,d3
  10586.     sub.l    d0,d3
  10587.     move.l    a3,d1
  10588.     jsr    _LVOClose(a6)
  10589.     moveq    #1,d0
  10590.     tst.l    d3
  10591.     beq.s    .A
  10592.     moveq    #0,d0
  10593. .A    move.l    d0,d2
  10594.     move.l    d4,d0
  10595.     move.l    a2,a1
  10596.     bsr    givemem
  10597.     tst.l    d2
  10598.     beq    DOSerr
  10599.     bra    reviewOK
  10600.  
  10601.     
  10602.  
  10603. *****    ReviewHandler    ********
  10604. RHa1    dc.w    $4ef9    JMP
  10605. RHa2    dcb.w    3    Return-Code
  10606. RHa3    dcb.l    1    Memory-Base-Table
  10607.  
  10608. RCode    movem.l    d0-d3/a5-a6,-(sp)    ;Is called by the DOS Write fkt.
  10609.     move.l    RHa3(pc),d0
  10610.     beq.s    .C
  10611.     move.l    d0,a0
  10612.     moveq    #20-1,d0
  10613. .B    move.l    (a0)+,a5
  10614.     cmp.l    outhandle(a5),d1
  10615.     beq.s    .A
  10616.     dbra    d0,.B
  10617.     bra.s    .C
  10618. .A    tst.b    noreview_flag(a5)
  10619.     bne.s    .C
  10620.     bsr    toreview
  10621. .C    movem.l    (sp)+,d0-d3/a5-a6
  10622.     bra.s    RHa1
  10623.  
  10624. toreview    ;Writes data to review-buffer,Entry: d2=Adress, d3=Length
  10625.     move.l    d2,a0
  10626.     move.l    ReviewMem(a5),a1
  10627.     move.l    ReviewPtr(a5),d1
  10628.     move.l    ReviewSize(a5),d2
  10629.     beq.s    .C
  10630.     bra.s    .B
  10631. .A    move.b    (a0)+,d0
  10632.     move.b    d0,0(a1,d1.l)
  10633.     addq.l    #1,d1
  10634.     cmp.l    d1,d2
  10635.     bhi.s    .B
  10636.     clr.l    d1
  10637. .B    dbra    d3,.A
  10638.     move.l    d1,ReviewPtr(a5)
  10639. .C    rts
  10640.  
  10641.  
  10642. **********************************************************************
  10643. ; check if string in a0 is same as in a1 (limited by null,comma,space)
  10644. ; return: d0=0 for match, 1 otherwise
  10645. CheckOpt
  10646.     move.l    a0,-(sp)
  10647. .A    move.b    (a1)+,d1    compare things
  10648.     beq.s    .B
  10649.     cmp.b    #" ",d1
  10650.     beq.s    .B
  10651.     cmp.b    #",",d1
  10652.     beq.s    .B
  10653.     move.b    (a0)+,d0
  10654.     beq.s    .H
  10655.     cmp.b    ctrl_codes+15(a5),d0    check for .
  10656.     bne.s    .F
  10657.     tst.b    (a0)
  10658.     beq.s    .G
  10659. .F    bsr    compD1D0nocase
  10660.     beq.s    .A
  10661. .H    moveq    #1,d0        failed (not matched)
  10662.     bra.s    .E
  10663. .G    moveq    #0,d0        success    (abbreviated)
  10664. .E    move.b    (a1)+,d1    search for end
  10665.     beq.s    .D
  10666.     cmp.b    #" ",d1
  10667.     beq.s    .D
  10668.     cmp.b    #",",d1
  10669.     bne.s    .E
  10670.     bra.s    .D
  10671. .B    moveq    #1,d0        success or a0 is too long ?
  10672.     tst.b    (a0)
  10673.     bne.s    .D
  10674.     moveq    #0,d0        length is same -> success
  10675. .D    move.l    (sp)+,a0
  10676.     tst.l    d0
  10677.     rts
  10678.  
  10679. *************************
  10680. ; check a0 for ON (d0=1) or OFF (d0=0) option, otherwise error-exit
  10681. CheckOnOff
  10682.     move.l    a2,-(sp)
  10683.     lea    onoffuse(pc),a2
  10684.     move.l    a0,d0
  10685.     beq.s    .B
  10686.     lea    6(a2),a1
  10687.     bsr    CheckOpt
  10688.     beq.s    .A
  10689.     move.l    a2,a1
  10690.     bsr    CheckOpt
  10691.     bne.s    .B
  10692.     moveq    #1,d0
  10693. .A    move.l    (sp)+,a2
  10694.     rts
  10695. .B    move.l    a2,a1
  10696. *************************
  10697. ; print error in a1 and exit
  10698. ErrorExit
  10699.     bsr    pr_stringlf
  10700.     bra    galactic
  10701.  
  10702. *************************
  10703. ; check for Kickstart 2.0 or better, exit on error
  10704. CheckKS    lea    oldkick_tx(pc),a1
  10705.     cmp.w    #36,kickver(a5)
  10706.     blo.s    ErrorExit
  10707.     rts
  10708.  
  10709. **********************************************************************
  10710. ; check if option in a0 is in parm-list and deletes it from parm-list
  10711. ; return: d0=0 for match, 1 otherwise
  10712. LookForOpt
  10713.     movem.l    a2-a3,-(sp)
  10714.     move.l    a0,a2
  10715.     lea    parm2(a5),a3
  10716. .A    move.l    (a3)+,d0    search all parms
  10717.     beq.s    .B
  10718.     move.l    a2,a1
  10719.     move.l    d0,a0
  10720.     bsr    CheckOpt    look for option
  10721.     bne.s    .A
  10722.     lea    -4(a3),a2    found it !
  10723. .D    move.l    (a3)+,(a2)+    delete found parm
  10724.     bne.s    .D
  10725.     moveq    #0,d0
  10726.     bra.s    .C
  10727. .B    moveq    #1,d0        not found !
  10728. .C    movem.l    (sp)+,a2-a3
  10729.     rts
  10730.  
  10731. *************************
  10732. *    MakeLink    *    V2.3
  10733. *************************
  10734. makelinkz
  10735.     bsr    CheckKS
  10736.     moveq    #0,d7
  10737.     moveq    #0,d3
  10738.     lea    linkuse(pc),a2
  10739.     move.l    parm4(a5),d0
  10740.     beq.s    .C
  10741.     move.l    d0,a0
  10742.     move.l    a2,a1
  10743.     bsr    CheckOpt
  10744.     beq.s    .B
  10745.     moveq    #-1,d3
  10746.     lea    8(a2),a1
  10747.     bsr    CheckOpt
  10748.     beq.s    .B
  10749. .C    move.l    a2,a1
  10750.     bra    ErrorExit
  10751. .B    move.l    parm3(a5),d1
  10752.     beq    too_less_args
  10753.     move.l    d1,d2
  10754.     tst.l    d3
  10755.     bne.s    .D
  10756.     moveq    #-2,d2
  10757.     jsr    _LVOLock(a6)
  10758.     move.l    d0,d7
  10759.     beq    DOSerr
  10760.     move.l    d0,d2
  10761. .D    move.l    parm2(a5),d1
  10762.     beq    too_less_args
  10763.     jsr    _LVOMakeLink(a6)
  10764.     tst.l    d0
  10765.     beq    DOSerrUL
  10766.     move.l    d7,d1
  10767.     beq.s    .A
  10768.     jsr    _LVOUnLock(a6)
  10769. .A    moveq    #RETURN_OK,d0
  10770.     rts
  10771.  
  10772. *************************
  10773. *    Flags        *    V2.3
  10774. *************************
  10775. flagsz    lea    parm2(a5),a3
  10776.     move.l    Flags(a5),d3
  10777. .A    move.l    (a3)+,d0
  10778.     beq.s    .F
  10779.     move.l    d0,a0
  10780.     lea    flagsuse(pc),a1
  10781.     moveq    #0,d2
  10782. .B    bsr    CheckOpt    look for flag
  10783.     beq.s    .D
  10784.     addq.w    #1,d2
  10785.     cmp.w    #MaxFlags,d2
  10786.     bne.s    .B
  10787.     lea    flagsuse(pc),a1
  10788.     bsr    pr_stringlf
  10789.     bra.s    .C
  10790. .D    move.l    (a3)+,a0    change flag
  10791.     bclr    d2,d3
  10792.     bsr    CheckOnOff
  10793.     beq.s    .A
  10794.     bset    d2,d3
  10795.     bra.s    .A
  10796.  
  10797. .F    moveq    #0,d2        print all flags
  10798.     lea    flagsuse(pc),a3
  10799. .E    lea    temp2buf(a5),a2
  10800. .G    move.b    (a3)+,d0
  10801.     move.b    d0,(a2)+
  10802.     cmp.b    #" ",d0
  10803.     beq.s    .H
  10804.     cmp.b    #",",d0
  10805.     bne.s    .G
  10806. .H    subq.l    #1,a2
  10807.     lea    flagsoff(pc),a1
  10808.     btst    d2,d3
  10809.     beq.s    .I
  10810.     lea    flagson(pc),a1
  10811. .I    bsr    addstring
  10812.     lea    temp2buf(a5),a1
  10813.     bsr    pr_string
  10814.     addq.w    #1,d2
  10815.     cmp.w    #MaxFlags,d2
  10816.     bne.s    .E
  10817.     move.l    d3,Flags(a5)
  10818. .C    moveq    #RETURN_OK,d0
  10819.     rts
  10820.  
  10821. *************************
  10822. *    MakeIcon    *    V2.3
  10823. *************************
  10824. makeiconz
  10825.     bsr    CheckKS
  10826.     move.l    parm2(a5),d3
  10827.     beq    too_less_args
  10828.     move.l    parm3(a5),d0
  10829.     beq.s    .E
  10830.     move.l    d0,a0
  10831.     moveq    #1,d2
  10832.     lea    iconuse(pc),a1
  10833. .D    bsr    CheckOpt
  10834.     beq.s    .C
  10835.     addq.l    #1,d2
  10836.     cmp.b    #9,d2
  10837.     bne.s    .D
  10838. .B    move.l    dosbase(a5),a6
  10839.     lea    iconuse(pc),a1
  10840.     bsr    pr_stringlf
  10841.     bra.s    .A
  10842. .C    bsr    OpenIconLib
  10843.     beq.s    .B
  10844.     move.l    d2,d0
  10845.     jsr    _LVOGetDefDiskObject(a6)
  10846.     move.l    d0,d2
  10847.     beq    resi_not_found
  10848.     move.l    d0,a1
  10849.     move.l    d3,a0
  10850.     jsr    _LVOPutDiskObject(a6)
  10851.     move.l    d0,d3
  10852.     move.l    d2,a0
  10853.     jsr    _LVOFreeDiskObject(a6)
  10854.     tst.l    d3
  10855.     beq    resi_not_found
  10856. .A    move.l    dosbase(a5),a6
  10857.     moveq    #RETURN_OK,d0
  10858.     rts
  10859.  
  10860. .E    ;shows icon using wb.lib's wbinfo
  10861.     cmp.w    #39,kickver(a5)        needs OS3.0+
  10862.     blo.s    .B
  10863.     bsr    OpenWBLib
  10864.     beq.s    .B
  10865.     move.l    thistask(a5),a0
  10866.     move.l    pr_CurrentDir(a0),a0
  10867.     move.l    parm2(a5),a1
  10868.     move.l    iconbase(a5),a2
  10869.     move.l    $38(a2),a2
  10870.     jsr    _LVOWBInfo(a6)
  10871.     bra.s    .A
  10872.  
  10873.  
  10874. recol1    dc.w    residetx+3-start,assign_tx+4-start,volume_tx+3-start
  10875.     dc.w    device1_tx+4-start,locktext+13-start
  10876.     dc.w    show_tx+2-start,show2_tx+2-start,shta_tx+2-start
  10877.     dc.w    proform+4-start,inform_tx+2-start,inform+24-start
  10878.     dc.w    inform2+15-start,stat_text+3-start,totsize+3-start
  10879.     dc.w    dirof+3-start,farb2+3-start,farb3+3-start
  10880.     dc.w    helpmor+3-start
  10881. recol2    ;Recolour-table to switch globally to one colour
  10882.     dc.b    2,2,2,2,3,2,2,2,3,2,7,5,7,7,6,2,3,2
  10883.  
  10884.  
  10885. * Localized Error-Messages
  10886. doserror_text
  10887.     dc.b     48,'*** BREAK ***',0        304
  10888.     dc.b     49,'Not executable',0        305
  10889.     dc.b    103,'No free Store',0
  10890.     dc.b    108,'Too small',0        -148
  10891.     dc.b    115,'Bad number',0
  10892.     dc.b    116,'Not enough arguments',0
  10893.     dc.b    135,'Command not found',0    -121
  10894.     dc.b    202,'Object in use',0
  10895.     dc.b    203,'Object '
  10896. exists        dc.b    'exists',0
  10897.     dc.b    204,'Dir not found',0
  10898.     dc.b    205,'Object'
  10899. notfund        dc.b    ' not found',0
  10900.     dc.b    209,'Action unknown',0
  10901.     dc.b    210,'Invalid Name',0
  10902.     dc.b    212,'Object wrong Type',0
  10903.     dc.b    213,'Not validated',0
  10904.     dc.b    214,'Disk write-protected',0
  10905.     dc.b    215,'Rename across Devices',0  
  10906.     dc.b    216,'Dir not empty',0
  10907.     dc.b    218,'Device not mounted',0
  10908.     dc.b    221,'Disk full',0
  10909.     dc.b    222,'Delete protected',0
  10910.     dc.b    223,'Write protected',0
  10911.     dc.b    225,'Not a DOS Disk',0
  10912.     dc.b    226,'No Disk present',0
  10913.  
  10914.     dc.b    101,'Error %3ld',0        -155
  10915.     dc.b    102,'Failat: %ld',10,0        -154
  10916.     dc.b    104,'Current Dir',0        -152
  10917.     dc.b    110,'Stack: %ld bytes',10,0    -146
  10918.     dc.b    127,'ZShell Process %ld',10,0    -129
  10919.     dc.b    0,0
  10920.  
  10921.  
  10922. * Standard-Strings
  10923. ZShellName    dc.b    'ZShell',0
  10924. dosname        dc.b    'dos.library',0
  10925. intuiname    dc.b    'intuition.library',0
  10926. iconname    dc.b    'icon.library',0
  10927. wbname        dc.b    'workbench.library',0
  10928. aslname        dc.b    'asl.library',0
  10929. guidename    dc.b    'amigaguide.library',0
  10930. timdev        dc.b    'timer.device',0
  10931. conname        dc.b    'CON:0/10/640/190/ZShell V2.5/CLOSE',0
  10932. connil        dc.b    'NIL:',0
  10933. wintool        dc.b    'WINDOW',0
  10934. screentool    dc.b    'SCREEN',0
  10935. scripttool    dc.b    'SCRIPT',0
  10936. norawtool    dc.b    'NORAW',0
  10937. commandtool    dc.b    'COMMAND',0
  10938. iconifytool    dc.b    'ICONIFY',0
  10939. xpostool    dc.b    'XPOS',0
  10940. ypostool    dc.b    'YPOS',0
  10941. nametool    dc.b    'ICONNAME',0
  10942. wbenchtx    dc.b    "Workbench",0
  10943. useit        dc.b    "Usage: ZShell [-Wwindow] [-Sscript]"
  10944.         dc.b    " [-Ccommand] [-N] [-D]",0
  10945. onoffuse    dc.b    "ON or OFF ?",0
  10946. flagsuse    dc.b    "CHECK,MATCH,ICON,WILD,ERRORS,DEBUG"
  10947.         dc.b    ",CUT,ALL,HIDE ?",0
  10948. iconuse        dc.b    "DISK,DRAWER,TOOL,PROJECT,GARBAGE"
  10949.         dc.b    ",DEVICE,KICK,APPICON ?",0
  10950. linkuse        dc.b    "HARD or SOFT ?",0
  10951. assignuse    dc.b    "REMOVE,ADD,PATH,DEFER ?",0
  10952. devicetx    dc.b    "DEVICE",0
  10953. forcetx        dc.b    "FORCE",0
  10954. alltx        dc.b    "ALL",0
  10955. oldkick_tx    dc.b    'Needs Kickstart 2.0+',0
  10956. defscript    dc.b    'S:ZStart',0    ;changed V2.0
  10957. rexxtx        dc.b    'REXX:RX',0
  10958. appicontx    dc.b    "Shell-It !",0
  10959. runit        dc.b    ';ask Press RETURN;endcli',0
  10960. runnil        dc.b    '-w',0
  10961. clkform        dc.b    ' Mem:%7ld Chip:%6ld  %02d:%02d:%02d ',0
  10962. warn_tx        dc.b    'warn',0
  10963. error_tx    dc.b    'error',0
  10964. fail_tx        dc.b    'fail',0
  10965. not_tx        dc.b    'not',0
  10966. badprotbit    dc.b    'Unknown flag',0
  10967. noclk_tx    dc.b    'No Clock',0
  10968. stack_tx    dc.b    'Stack overflow',0
  10969. view1_tx    dc.b    ' Bytes',10,0
  10970. residetx    dc.b    27,'[32mUsecount  Name',27,'[m',0
  10971. rpn_result_tx    dc.b    'RESULT: Dec %ld  Hex $%08lx',10,0
  10972. rpn_res2    dc.b    '%ld',0
  10973. unmounted_tx    dc.b    '[Un'
  10974. mounted_tx    dc.b    'Mounted]',0
  10975. assign_tx    dc.b    10,27,'[32mAssigns:',27,'[m',10,0
  10976. volume_tx    dc.b    27,'[32mVolumes:',27,'[m',10,0
  10977. device1_tx    dc.b    10,27,'[32m',0
  10978. device2_tx    dc.b    'Disk-'
  10979. device3_tx    dc.b    'Devices:',27,'[m',10,0
  10980. prompt_args_tx    dc.b    4,'%s> ',0
  10981. lockntx        dc.b    'Give LOCK-BPTR or NAME',0
  10982. lockread    dc.b    'READ',0
  10983. lockwrite    dc.b    'WRITE',0
  10984. locktext    dc.b    '%s-Lock on ',$9b,'33m%s',$9b,'m'
  10985.         dc.b    10,'This: $%06lx  Next: $%06lx',10,0
  10986. clk_tx        dc.b    'LOAD or SAVE ?',0
  10987. muell_tx    dc.b    'Format: DD.MM.YY or MM-DD-YY or HH:MM:SS',0
  10988. styp        dc.b    'lrdimps'
  10989. shuse_tx    dc.b    'Use D,I,L,M,P,R,S,T or V',0
  10990. show_tx        dc.b    $9b,'32mAdress Pri Name',$9b,'m',0
  10991. show2_tx    dc.b    $9b,'32mAdress Pri Ver Rev Name',$9b,'m',0
  10992. shform        dc.b    '%06lx%4d %s',10,0
  10993. shform2        dc.b    '%06lx%4d%4d%4d %s',10,0
  10994. shta_tx        dc.b    $9b,'32mAdress Pri State SignWait PT '
  10995.         dc.b    'Name',$9b,'m',0
  10996. shtaform    dc.b    '%06lx%4d %-5s %08lx %c%c %s',0
  10997. proform        dc.b    32,9,$9b,'33m->%sCLI %ld:',$9b,'m %s %s%s',0
  10998. backcli        dc.b    "Bg-",0
  10999. ttyp        dc.b    "Inval",0,"Added",0,"Run",0,"Ready",0
  11000.         dc.b    "Wait",0,"Exept",0,"Remov",0
  11001. inform_tx    dc.b    $9b,'32mName Unit Sys    Size    Free Full Block'
  11002.         dc.b    '   Status   Err  Volume',$9b,'m',0
  11003. inform        dc.b    '%-7s%2ld %3s%7ldK%7ldK',$9b,'37m%4ld%%',$9b
  11004.         dc.b    'm%6ld %-10s%3ld   %s',10,0
  11005. inform2        dc.b    '%-7s%2ld     ',$9b,'35m%s',$9b,'m',10,0
  11006. statro        dc.b    "Read only",0
  11007. statrw        dc.b    "Read/Write",0
  11008. statval        dc.b    "Validating",0
  11009. statun        dc.b    "Unknown",0
  11010. kickdisk    dc.b    "Kick",0
  11011. ofs_tx        dc.b    "OFS",0    OldFilesystem
  11012.         dc.b    "FFS",0    FastFilesystem
  11013.         dc.b    "OIN",0    International OFS
  11014.         dc.b    "FIN",0    International FFS
  11015.         dc.b    "ODC",0    Dir Cache OFS
  11016.         dc.b    "FDC",0 Dir Cache FFS
  11017. msd_tx        dc.b    "MSD",0    MessyDOS
  11018. quest_tx    dc.b    "???",0    Unknown
  11019. msendtx        dc.b    "sent",0
  11020. pra5tx        dc.b    "A5=%06lx",10,0
  11021. msgtx        dc.b    "Message=%06lx  Length=%d",10,0
  11022. time_text    dc.b    "Date: %02d.%02d.%02d    "
  11023.         dc.b    "Time: %02d:%02d:%02d.%02d",10,0
  11024. stat_text    dc.b    27,"[37mResult2=%ld  Time=%02d:%02d:%02d.%02d"
  11025.         dc.b    "  Changes-> Chip:%ld  Fast:%ld  Total:%ld"
  11026.         dc.b    27,"[m",10,0
  11027. lockleft    dc.b    "Locks: %ld -> %ld",10,0
  11028. lowmemtx    dc.b    "Changed %06lx: %08lx -> %08lx",10,0
  11029. replytx        dc.b    "Reply? ",0
  11030. mem_line    dc.b    "%08lx: %08lx %08lx %08lx %08lx   '%s'",10,0
  11031. vec_line    dc.b    "Warm $%08lx MemPtr $%08lx",10
  11032.         dc.b    "Cool $%08lx TagPtr $%08lx",10
  11033.         dc.b    "Cold $%08lx Check  $%08lx",10,0
  11034. formatask    dc.b    "Delete whole disk ? ",0
  11035. addbufftx    dc.b    "%s has %ld buffers",10,0
  11036. pfeil        dc.b    "-> ",0
  11037. flagsoff    dc.b    ": OFF",10,0
  11038. flagson        dc.b    ": ON",10,0
  11039. Forbidtx    dc.b    "Forbid,Disable!",0
  11040.  
  11041. format        dc.b    '%8ld',0    ;print a longw right justified
  11042. formatADR    dc.b    '$%06lx',0    ;print address 
  11043. totsize        dc.b    27,'[37mTotal Bytes: %ld  Blocks: %ld   '
  11044.         dc.b    'Files: %ld  Dirs: %ld',27,'[m',10,0
  11045. dirtext        dc.b    '(Dir)',27,'[m',0
  11046. dirof        dc.b    27,'[36mDirectory of ',27,'[m',0
  11047. paths        dc.b    "S:",0
  11048. msearch        dc.b    12,$9b,'BSearch: ',$9b," p",0
  11049. mjump        dc.b    12,$9b,'BJump to %: ',$9b," p",0
  11050. mwrite        dc.b    12,$9b,'BWrite to: ',$9b," p",0
  11051. wrongsize    dc.b    'New size:',0
  11052. makedirOK    dc.b    'created',10,0
  11053. copyOK        dc.b    'copied',10,0
  11054. moveOK        dc.b    'moved',10,0
  11055. joinOK        dc.b    'processed',10,0
  11056. deleteOK    dc.b    'deleted',10,0
  11057. yesnotx        dc.b    'Yes/No/All/Quit ? ',0
  11058. memess        dc.b    "Chip: %ld  Fast: %ld  Total Free: %ld",10,0
  11059.  
  11060. star        dc.b    "*",0
  11061. dot        dc.b    ".",0
  11062. smaller        dc.b    "<",0
  11063. bigger        dc.b    ">",0
  11064. lf        dc.b    10,0
  11065. tab        dc.b    9,0
  11066. space        dc.b    " "
  11067. null        dc.b    0
  11068. help_ret    dc.b    "help^M",0
  11069. farb1        dc.b    27,'[m',0
  11070. farb2        dc.b    27,'[32m',0
  11071. farb3        dc.b    27,'[33m',0
  11072. backspace_it    dc.b    8        DON'T SEPERATE
  11073. delete_it    dc.b    $9b,'P',0        THESE LINES
  11074. return_it    dc.b    13,10,0
  11075. delete_line    dc.b    13,$9b,'M',0
  11076. clstx        dc.b    27,"c",0    reset console
  11077. clrtx        dc.b    12,0    clear screen
  11078. scroll_up_tx    dc.b    $9b,"S",13,0
  11079. scroll_down_tx    dc.b    $9b,"M",$9b,"T",$9b,"1H",0
  11080. clrhide        dc.b    12
  11081. hide_cursor    dc.b    $9b,"0 p",0
  11082. show_cursor    dc.b    $9b," p",0
  11083. askforsize    dc.b    $9b," q",0
  11084. cutontx        dc.b    $9b,"?7l",0
  11085. cutofftx    dc.b    $9b,"?7h",0
  11086.  
  11087. ctrl_tx    dc.b    'Actual CTRL-Codes: ',0
  11088. ctrl_init dc.b    23,17,19,5,9,24,27,20,25,8,10,13,12,18,22,46 CTRL-Codes
  11089. ctrl_inite
  11090.  
  11091. helpld    dc.b    "Loading "
  11092. helpman    dc.b    "ZShell.doc",0
  11093. helpmor    dc.b    13,$9b,"32m %d%% %ld bytes. Use: (shift+)cursor,"
  11094.     dc.b    "(back)space,numeric,s,j,w,r,h",$9b,"K",$9b,"m",0
  11095. helptx1 dc.b    '$VER: ZShell V2.5 (07.04.95)',10
  11096.     dc.b    "(C)1990,91 Paul Hayter (V1.3); "
  11097.     dc.b    "Updated 1993-95 by Martin Gierich.",10
  11098.     dc.b    "Freeware, NO commercial usage !",10
  11099.     dc.b    "Please send your comments to"
  11100.     dc.b    " uj3w@rz.uni-karlsruhe.de",10,10
  11101.     dc.b    "Commands:",0
  11102. helptx2 dc.b    10,"Options:",10
  11103.     dc.b    "-r/-RECURSIVE: copy,ctrl,delete,dir,join,list,move,protect,",10
  11104.     dc.b    "-c/-CLEAR: avail,ctrl,endcli,locate,path,resident,run",10
  11105.     dc.b    "-q/-QUICK: dir,join,list,delete",10
  11106.     dc.b    10,"Wildcards: * ? ~ [] |",10
  11107.     dc.b    "Editing: (SHIFT+) Cursor, <-, DEL,"
  11108.     dc.b    " (SHIFT+) TAB, ESC and see ctrl",10
  11109.     dc.b    ". for dir back, force disk or abbreviation",10
  11110.     dc.b    "Type 'help ?' for more help.",0
  11111. helptx3
  11112.  
  11113. *********************************************
  11114.  
  11115. comtext    dc.b    'addbuffers',0    V1.27
  11116.     dc.b    'alias',0
  11117.     dc.b    'ask',0        V1.28
  11118.     dc.b    'assign',0
  11119.     dc.b    'avail',0
  11120.     dc.b    'border',0    V2.0
  11121.     dc.b    'break',0    V2.0
  11122.     dc.b    'cd',0
  11123.     dc.b    'cls',0        V2.0
  11124.     dc.b    'copy',0
  11125.     dc.b    'ctrl',0    V2.0
  11126.     dc.b    'date',0
  11127.     dc.b    'diskchange',0    V2.0
  11128.     dc.b    'delete',0
  11129.     dc.b    'die',0        V2.0
  11130.     dc.b    'dir',0
  11131.     dc.b    'echo',0
  11132. elsetx    dc.b    'else',0    V1.28
  11133. endcltx    dc.b    'endcli',0
  11134. endiftx dc.b    'endif',0    V1.28
  11135.     dc.b    'eval',0
  11136. exectx    dc.b    'execute',0
  11137.     dc.b    'failat',0
  11138.     dc.b    'fault',0    V2.0
  11139.     dc.b    'filenote',0    V2.0
  11140.     dc.b    'flags',0    V2.3
  11141.     dc.b    'getmsg',0    V2.0
  11142.     dc.b    'help',0
  11143.     dc.b    'htype',0    V1.29
  11144.     dc.b    'if',0        V1.28
  11145.     dc.b    'info',0
  11146.     dc.b    'join',0    V1.29
  11147. labeltx dc.b    'lab',0        V1.29
  11148.     dc.b    'list',0
  11149.     dc.b    'locate',0    V2.0
  11150.     dc.b    'lock',0    V2.0
  11151.     dc.b    'm',0
  11152.     dc.b    'makedir',0
  11153.     dc.b    'makeicon',0    V2.3
  11154.     dc.b    'makelink',0    V2.3
  11155. clktask    dc.b    'memclk',0    V2.0
  11156.     dc.b    'more',0    V1.23
  11157.     dc.b    'move',0    V2.3
  11158.     dc.b    'newcli',0    V2.0
  11159.     dc.b    'path',0
  11160.     dc.b    'prompt',0
  11161.     dc.b    'protect',0
  11162.     dc.b    'putmsg',0    V2.0
  11163.     dc.b    'quit',0    V1.29
  11164.     dc.b    'relabel',0    V1.27
  11165.     dc.b    'rename',0
  11166.     dc.b    'resident',0    V1.25
  11167.     dc.b    'review',0    V2.1
  11168.     dc.b    'run',0        V2.2
  11169.     dc.b    'search',0    V2.0
  11170.     dc.b    'setclock',0    V2.0
  11171.     dc.b    'setdate',0    V2.0
  11172.     dc.b    'show',0    V2.0
  11173.     dc.b    'skip',0
  11174.     dc.b    'stack',0
  11175.     dc.b    'strings',0    V1.29
  11176.     dc.b    'taskpri',0    V2.0
  11177.     dc.b    'type',0
  11178.     dc.b    'unalias',0
  11179.     dc.b    'wait',0
  11180.     dc.b    0
  11181.     
  11182.     
  11183.     cnop    0,2
  11184. comoffs
  11185.     dc.w    addbuffersz-start
  11186.     dc.w    set_funcz-start    ;alias
  11187.     dc.w    askz-start
  11188.     dc.w    assignz-start
  11189.     dc.w    availz-start
  11190.     dc.w    borderz-start
  11191.     dc.w    breakz-start
  11192.     dc.w    cdz-start
  11193.     dc.w    clsz-start
  11194.     dc.w    copyz-start
  11195.     dc.w    ctrlz-start
  11196.     dc.w    datez-start
  11197.     dc.w    diskchangez-start
  11198.     dc.w    deletez-start
  11199.     dc.w    diez-start
  11200.     dc.w    dirz-start
  11201.     dc.w    echoz-start
  11202.     dc.w    elsez-start
  11203.     dc.w    endcliz-start
  11204.     dc.w    endifz-start
  11205.     dc.w    evalz-start
  11206.     dc.w    executez-start
  11207.     dc.w    failatz-start
  11208.     dc.w    faultz-start
  11209.     dc.w    filenotez-start
  11210.     dc.w    flagsz-start
  11211.     dc.w    getmsgz-start
  11212.     dc.w    helpz-start
  11213.     dc.w    htypez-start
  11214.     dc.w    ifz-start
  11215.     dc.w    infoz-start
  11216.     dc.w    joinz-start
  11217.     dc.w    labelz-start    ;lab
  11218.     dc.w    listz-start
  11219.     dc.w    locatez-start
  11220.     dc.w    lockz-start
  11221.     dc.w    memexamz-start    ;m
  11222.     dc.w    makedirz-start
  11223.     dc.w    makeiconz-start
  11224.     dc.w    makelinkz-start
  11225.     dc.w    memclkz-start
  11226.     dc.w    morez-start
  11227.     dc.w    movez-start
  11228.     dc.w    newcliz-start
  11229.     dc.w    pathz-start
  11230.     dc.w    promptz-start
  11231.     dc.w    protectz-start
  11232.     dc.w    putmsgz-start
  11233.     dc.w    quitz-start
  11234.     dc.w    relabelz-start
  11235.     dc.w    renamez-start
  11236.     dc.w    residentz-start
  11237.     dc.w    reviewz-start
  11238.     dc.w    runz-start
  11239.     dc.w    searchz-start
  11240.     dc.w    setclockz-start
  11241.     dc.w    setdatez-start
  11242.     dc.w    showz-start
  11243.     dc.w    skipz-start
  11244.     dc.w    stackz-start
  11245.     dc.w    stringsz-start
  11246.     dc.w    taskpriz-start
  11247.     dc.w    typez-start
  11248.     dc.w    unsetz-start    ;unalias
  11249.     dc.w    waitz-start
  11250.  
  11251. manadr    dc.l    0    here are 2 global variables
  11252. mansize    dc.l    0    because the online-help-manual is used globally
  11253.  
  11254.     end    ;***    here it ends    ***
  11255.  
  11256.